Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

  1. On Error Resume Next
  2. while true
  3. 'Ask for non-existent class to force error from CIMOM
  4. Set t_Service = GetObject("winmgmts://./root/default")
  5. Set t_Object = t_Service.Get("Nosuchclass000")
  6. if Err = 0 Then
  7. WScript.Echo "Got a class"
  8. Else
  9. WScript.Echo ""
  10. WScript.Echo "Err Information:"
  11. WScript.Echo ""
  12. WScript.Echo " Source:", Err.Source
  13. WScript.Echo " Description:", Err.Description
  14. WScript.Echo " Number", Err.Number
  15. 'Create the last error object
  16. set t_Object = CreateObject("WbemScripting.SWbemLastError")
  17. WScript.Echo ""
  18. WScript.Echo "WBEM Last Error Information:"
  19. WScript.Echo ""
  20. WScript.Echo " Operation:", t_Object.Operation
  21. WScript.Echo " Provider:", t_Object.ProviderName
  22. strDescr = t_Object.Description
  23. strPInfo = t_Object.ParameterInfo
  24. strCode = t_Object.StatusCode
  25. if (strDescr <> nothing) Then
  26. WScript.Echo " Description:", strDescr
  27. end if
  28. if (strPInfo <> nothing) Then
  29. WScript.Echo " Parameter Info:", strPInfo
  30. end if
  31. if (strCode <> nothing) Then
  32. WScript.Echo " Status:", strCode
  33. end if
  34. WScript.Echo ""
  35. Err.Clear
  36. set t_Object2 = CreateObject("WbemScripting.SWbemLastError")
  37. if Err = 0 Then
  38. WScript.Echo "Got the error object again - this shouldn't have happened!"
  39. Else
  40. Err.Clear
  41. WScript.Echo "Couldn't get last error again - as expected"
  42. End if
  43. End If
  44. wend