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.

108 lines
3.8 KiB

  1. on error resume next
  2. '// Create a new shadow
  3. set Shadow = GetObject("winmgmts:Win32_ShadowCopy")
  4. set Storage = GetObject("winmgmts:Win32_ShadowStorage")
  5. Result = 0
  6. Result = Shadow.Create(Null, Null, Null)
  7. rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
  8. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  9. if Result <> 0 then
  10. wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
  11. end if
  12. Result = 0
  13. Result = Shadow.Create("BogusVolumeName", "ClientAccessible", strShadowID)
  14. rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
  15. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  16. if Result <> 0 then
  17. wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
  18. end if
  19. Result = 0
  20. Result = Shadow.Create(-1, "ClientAccessible", strShadowID)
  21. rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
  22. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  23. if Result <> 0 then
  24. wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
  25. end if
  26. Result = 0
  27. Result = Shadow.Create("c:\", "BogusContext", strShadowID)
  28. rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
  29. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  30. if Result <> 0 then
  31. wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
  32. end if
  33. Result = 0
  34. Result = Shadow.Create("c:\", -1, strShadowID)
  35. rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
  36. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  37. if Result <> 0 then
  38. wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
  39. end if
  40. Result = 0
  41. Result = Storage.Create(Null, Null, Null)
  42. rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
  43. strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
  44. if Result <> 0 then
  45. wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
  46. end if
  47. Result = 0
  48. Result = Storage.Create("BogusVolumeName", "C:\", Null)
  49. rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
  50. strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
  51. if Result <> 0 then
  52. wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
  53. end if
  54. Result = 0
  55. Result = Storage.Create("C:\", "BogusVolumeName", Null)
  56. rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
  57. strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
  58. if Result <> 0 then
  59. wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
  60. end if
  61. Result = Null
  62. Result = Storage.Create("C:\", "C:\", "BogusMaxSpaceValue")
  63. rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
  64. strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
  65. if Result <> 0 then
  66. wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
  67. end if
  68. Result = Null
  69. Result = Storage.Create("C:\", "C:\", -1)
  70. rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
  71. strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
  72. if Result <> 0 then
  73. wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
  74. end if
  75. Result = Null
  76. Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
  77. set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
  78. set objMethod = objClass.methods_(strMethod)
  79. values = objMethod.qualifiers_("values")
  80. if ubound(values) < intCode then
  81. wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
  82. MapErrorCode = ""
  83. else
  84. MapErrorCode = values(intCode)
  85. end if
  86. End Function
  87. Function ReportIfErr(ByRef objErr, ByRef strMessage)
  88. ReportIfErr = objErr.Number
  89. if objErr.Number <> 0 then
  90. strError = strMessage & " : " & Hex(objErr.Number) & " : " & objErr.Description
  91. wscript.echo (strError)
  92. objErr.Clear
  93. end if
  94. End Function