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.

57 lines
1.4 KiB

  1. '//on error resume next
  2. intLimit = Null
  3. intThreshold = Null
  4. set objArgs = wscript.Arguments
  5. if objArgs.count < 3 then
  6. wscript.echo "Usage createVolumeUserQuota volume domain user [limit threshold]"
  7. wscript.quit(1)
  8. end if
  9. strVolume = Replace(objArgs(0), "\", "\\")
  10. strDomain = objArgs(1)
  11. strUser = objArgs(2)
  12. if objArgs.count > 3 then
  13. intLimit = objArgs(3)
  14. intThreshold = objArgs(4)
  15. end if
  16. '// Get the volume
  17. strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
  18. set objSet = GetObject("winmgmts:").ExecQuery(strQuery)
  19. for each obj in objSet
  20. set Volume = obj
  21. exit for
  22. next
  23. wscript.echo "Volume: " & Volume.Name
  24. '// Get the account
  25. strQuery = "select * from Win32_Account where Domain = '" & strDomain & "' AND Name = '" & strUser & "'"
  26. set objSet = GetObject("winmgmts:").ExecQuery(strQuery)
  27. for each obj in objSet
  28. set Account = obj
  29. exit for
  30. next
  31. wscript.echo "Domain: " & Account.Domain & " Name: " & Account.Name
  32. set VolumeUserQuota = GetObject("winmgmts:Win32_VolumeUserQuota").SpawnInstance_
  33. VolumeUserQuota.Volume = Volume.Path_.RelPath
  34. VolumeUserQuota.Account = Account.Path_.RelPath
  35. 'VolumeUserQuota.Account = "Win32_Account.Domain='BogusDomain',Name='BogusUser'"
  36. if isNull(intLimit) = False Then
  37. VolumeUserQuota.Limit = intLimit
  38. end if
  39. if isNull(intThreshold) = False Then
  40. VolumeUserQuota.WarningLimit = intThreshold
  41. end if
  42. VolumeUserQuota.Put_