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.

53 lines
1.3 KiB

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