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.

44 lines
1.4 KiB

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