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.

35 lines
983 B

  1. on error resume next
  2. set objArgs = wscript.Arguments
  3. if objArgs.count < 2 then
  4. wscript.echo "Usage setDriveLetter volume <driveletter>:"
  5. wscript.quit(1)
  6. end if
  7. strVolume = Replace(objArgs(0), "\", "\\")
  8. strDriveLetter = objArgs(1)
  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: " & Volume.Name
  17. wscript.echo "DriveLetter: " & strDriveLetter
  18. Volume.DriveLetter = strDriveLetter
  19. Volume.Put_
  20. if Err.Number <> 0 then
  21. Set objLastError = CreateObject("wbemscripting.swbemlasterror")
  22. wscript.echo("Provider: " & objLastError.ProviderName)
  23. wscript.echo("Operation: " & objLastError.Operation)
  24. wscript.echo("Description: " & objLastError.Description)
  25. wscript.echo("StatusCode: 0x" & Hex(objLastError.StatusCode))
  26. end if