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.

41 lines
1.3 KiB

  1. '//on error resume next
  2. set objArgs = wscript.Arguments
  3. if objArgs.count < 1 then
  4. wscript.echo "Usage format volume [Current Defaults: filesystem=NTFS Quick=FALSE ClusterSize=4096 Label=NULL EnableCompression=FALSE]"
  5. wscript.quit(1)
  6. end if
  7. strVolume = Replace(objArgs(0), "\", "\\")
  8. '// Get the volume
  9. strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
  10. set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
  11. for each obj in VolumeSet
  12. set Volume = obj
  13. exit for
  14. next
  15. wscript.echo "Volume: " & Volume.Name
  16. Result = Volume.Format()
  17. strMessage = MapErrorCode("Win32_Volume", "Format", Result)
  18. wscript.echo "Volume.Format returned: " & Result & " : " & strMessage
  19. Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
  20. set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
  21. set objMethod = objClass.methods_(strMethod)
  22. values = objMethod.qualifiers_("values")
  23. if ubound(values) < intCode then
  24. wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
  25. f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
  26. MapErrorCode = ""
  27. else
  28. MapErrorCode = values(intCode)
  29. end if
  30. End Function