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
41 lines
1.3 KiB
'//on error resume next
|
|
|
|
set objArgs = wscript.Arguments
|
|
|
|
if objArgs.count < 1 then
|
|
wscript.echo "Usage format volume [Current Defaults: filesystem=NTFS Quick=FALSE ClusterSize=4096 Label=NULL EnableCompression=FALSE]"
|
|
|
|
wscript.quit(1)
|
|
end if
|
|
|
|
strVolume = Replace(objArgs(0), "\", "\\")
|
|
|
|
'// Get the volume
|
|
strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
|
|
|
|
set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
|
|
|
|
for each obj in VolumeSet
|
|
set Volume = obj
|
|
exit for
|
|
next
|
|
|
|
|
|
wscript.echo "Volume: " & Volume.Name
|
|
|
|
Result = Volume.Format()
|
|
strMessage = MapErrorCode("Win32_Volume", "Format", Result)
|
|
wscript.echo "Volume.Format returned: " & Result & " : " & strMessage
|
|
|
|
Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
|
|
set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
|
|
set objMethod = objClass.methods_(strMethod)
|
|
values = objMethod.qualifiers_("values")
|
|
if ubound(values) < intCode then
|
|
wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
|
|
f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
|
|
MapErrorCode = ""
|
|
else
|
|
MapErrorCode = values(intCode)
|
|
end if
|
|
End Function
|