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.

67 lines
2.1 KiB

  1. strNamespace = "winmgmts://./root/cimv2"
  2. set dateTime = CreateObject("WbemScripting.SWbemDateTime")
  3. set objArgs = wscript.Arguments
  4. if objArgs.count < 1 then
  5. wscript.echo "Usage shadow volume"
  6. wscript.quit(1)
  7. end if
  8. strVolume = Replace(objArgs(0), "\", "\\")
  9. '// Get the volume
  10. strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
  11. set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
  12. for each obj in VolumeSet
  13. set Volume = obj
  14. exit for
  15. next
  16. wscript.echo "Volume Name: " & Volume.DeviceID
  17. '// Pick a shadow context
  18. set ContextSet = GetObject(strNamespace).ExecQuery(_
  19. "select * from Win32_ShadowContext where Name='ClientAccessible'")
  20. for each obj in ContextSet
  21. set Context = obj
  22. exit for
  23. next
  24. wscript.echo "Context Name: " & Context.Name
  25. '// Create a new shadow
  26. set Shadow = GetObject(strNamespace & ":Win32_ShadowCopy")
  27. dateTime.SetVarDate(CDate(Now))
  28. Result = Shadow.Create(Volume.Name,_
  29. Context.Name,_
  30. strShadowID)
  31. strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
  32. wscript.echo "Shadow.Create returned: " & Result & " : " & strMessage
  33. if Result = 0 then
  34. wscript.echo "Shadow.ID: " & strShadowID
  35. strShadow = "Win32_ShadowCopy.ID='" & strShadowID & "'"
  36. wscript.echo strShadow
  37. set objShadow = GetObject(strNamespace).Get(strShadow)
  38. wscript.echo "Shadow.Create started at: " & dateTime.GetVarDate(True)
  39. dateTime.Value = objShadow.InstallDate
  40. wscript.echo "Shadow.InstallDate: " & dateTime.GetVarDate(True)
  41. end if
  42. Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
  43. set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
  44. set objMethod = objClass.methods_(strMethod)
  45. values = objMethod.qualifiers_("values")
  46. if ubound(values) < intCode then
  47. wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
  48. f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
  49. MapErrorCode = ""
  50. else
  51. MapErrorCode = values(intCode)
  52. end if
  53. End Function