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.

48 lines
1.5 KiB

  1. '//on error resume next
  2. bPermanent = False
  3. bForce = False
  4. set objArgs = wscript.Arguments
  5. if objArgs.count < 1 then
  6. wscript.echo "Usage dismount volume [ForceFlag] [PermanentFlag]"
  7. wscript.quit(1)
  8. end if
  9. strVolume = Replace(objArgs(0), "\", "\\")
  10. if objArgs.count > 1 then
  11. bForce = objArgs(1)
  12. end if
  13. if objArgs.count > 2 then
  14. bPermanent = objArgs(2)
  15. end if
  16. '// Get the volume
  17. strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
  18. set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
  19. for each obj in VolumeSet
  20. set Volume = obj
  21. exit for
  22. next
  23. wscript.echo "Volume: " & Volume.Name
  24. wscript.echo "Force: " & bForce
  25. wscript.echo "Permanent: " & bPermanent
  26. Result = Volume.Dismount(bForce, bPermanent)
  27. strMessage = MapErrorCode("Win32_Volume", "Dismount", Result)
  28. wscript.echo "Volume.Dismount returned: " & Result & " : " & strMessage
  29. Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
  30. set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
  31. set objMethod = objClass.methods_(strMethod)
  32. values = objMethod.qualifiers_("values")
  33. if ubound(values) < intCode then
  34. wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
  35. f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
  36. MapErrorCode = ""
  37. else
  38. MapErrorCode = values(intCode)
  39. end if
  40. End Function