| | |
VBScript disk quota program - whats up?
![]() |
Hello - here's my problem - trying to set up a lil bit of code that checks win2k disk quota and warns user if they are approaching their disk space threshold.
here's the code - (cut down for simplicity - this version doesnt really do much but should work)
Dim vol, quotauser
Set vol = CreateObject("Microsoft.DiskQuota.1")
vol.Initialize "C:\", false
quotauser = vol.finduser("insert user name here")
if quotauser.quotaused >= quotauser.threshold then
msgbox("Warning - nearing disk space limit")
end if
ok - so - why won't this work? - on running the script (by double-clicking the .vbs icon on my desktop cos I aint running it over our net til I know it works safely) - I get the following error message from Windows Script Host
Line:4
Char:1
Error: Object doesn't support this property or method
Code: 800A01B6
weird - especially since I found the finduser method of the diskquotacontrol object right there on msdn site - so - anyone got any ideas?
Thanks
here's the code - (cut down for simplicity - this version doesnt really do much but should work)
Dim vol, quotauser
Set vol = CreateObject("Microsoft.DiskQuota.1")
vol.Initialize "C:\", false
quotauser = vol.finduser("insert user name here")
if quotauser.quotaused >= quotauser.threshold then
msgbox("Warning - nearing disk space limit")
end if
ok - so - why won't this work? - on running the script (by double-clicking the .vbs icon on my desktop cos I aint running it over our net til I know it works safely) - I get the following error message from Windows Script Host
Line:4
Char:1
Error: Object doesn't support this property or method
Code: 800A01B6
weird - especially since I found the finduser method of the diskquotacontrol object right there on msdn site - so - anyone got any ideas?
Thanks
Don't have the answer but here is some related script that may point you in the right direction.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Author: Jason Tanem Description: This script reads in the names of drives and sends an email warning via Outlook if finds that a drive is below 2.5 GB free. Script: '= This script reads in the names of drives = '= <vDriveList> and sends an email warning via = '= Outlook if finds that a drive is below 2.5 GB = '= of free space. = '= = '= The text file <vDriveLlist> format should contain = '= one drive entry per line as follows: = '= = '= C = '= D = '= \\server\resource name = '============== 'Written by Jason Tanem '------------Declarations------- dim vFileSys, vShell, vLowIndicator, vDrv dim vDrvFree, vOutlook, vMessage, vMailTo dim vDriveList, vOpenText, vTextLine vDriveList = "C:\Temp\Shares.txt" '-------------Functions------ 'Boolean for space above or below 2.5 GB Function FreeSpaceStatus(drvPath) set vFileSys = CreateObject("Scripting.FileSystemObject") set vDrv = vFileSys.GetDrive(drvPath) vLowIndicator = "OK" If FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 0) < 2.5 Then vLowIndicator = "Low" End If FreeSpaceStatus = vLowIndicator End Function 'This function returns drive free space in GB '----------- Function FreeSpace(drvPath) Set vFileSYs = CreateObject("Scripting.FileSystemObject") Set vDrv = vFileSys.GetDrive(drvPath) vDrvFree = FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 2) & " GB" FreeSpace = vDrvFree End Function '------------Main------ Set vFileSys = CreateObject("Scripting.FileSystemObject") Set vOpenText = vFileSys.OpenTextFile(vDriveList) Do While vOpenText.AtEndOfStream <> True vTextLine = vOpenText.ReadLine If FreeSpaceStatus(vTextLine) = "Low" Then 'Create and send the email by calling on Outlook via COM '---------------- Set vOutlook = CreateObject("Outlook.Application") Set vMessage = vOutlook.CreateItem(0) With vMessage Set vMailTo = vMessage.Recipients.Add("jptanem@mapllc.com") vMailTo.Type = 1 .Subject = "Low drive space on network resource" .Body = vTextLine & " is down to " & FreeSpace(vTextLine) .Importance = 2 .Send End With End If Loop 'Clean Up '--- set vFileSys = Nothing Set vShell = Nothing Set vOpenText = Nothing Set vOutlook = Nothing Set vMessage = Nothing WScript.Quit
Thanks Paladine - that helps me with another problem I wanted to sort out, but doesnt really help with interfacing the script to DiskQuota. I want ultimately to include this script in the users login script ( over 1000 users on this network) so they can be notified on login of their personal disk space status. any ideas?
QkSTechTrainee;
Sorry I don't have any other ideas at the moment, but I can post the website I got that script from, it may have something else that can help.
Problem is, I am at work and the site address is at home, (google was no help) so I will post back later on...k!?!
Sorry I don't have any other ideas at the moment, but I can post the website I got that script from, it may have something else that can help.
Problem is, I am at work and the site address is at home, (google was no help) so I will post back later on...k!?!
•
•
Join Date: Mar 2004
Posts: 1
Reputation:
Solved Threads: 0
set objDiskQuota=Createobject("Microsoft.Diskquota.1")
objDiskQuota.Initialize "D:\", True
objDiskQuota.LogQuotaThreshold =True
set objUser=objDiskQuota.FindUser("domain\" & "username")
QuotaLimit = objUser.QuotaLimit / 1048576
PercentageQuotaUsed = int(100*(objUser.QuotaUsed / objUser.QuotaLimit ))
The Above works fine on our webfarm for showing website quota's so should work fine for you as well.
Diskquota's are dodgy as hell btw I have enountered many exception errors while writing a perl version of the above plus we had problems with the finduser not finding the user till the 2nd attempt with no reason why.
Make sure you test the user exists then loop the finduser part to get around this.
objDiskQuota.Initialize "D:\", True
objDiskQuota.LogQuotaThreshold =True
set objUser=objDiskQuota.FindUser("domain\" & "username")
QuotaLimit = objUser.QuotaLimit / 1048576
PercentageQuotaUsed = int(100*(objUser.QuotaUsed / objUser.QuotaLimit ))
The Above works fine on our webfarm for showing website quota's so should work fine for you as well.
Diskquota's are dodgy as hell btw I have enountered many exception errors while writing a perl version of the above plus we had problems with the finduser not finding the user till the 2nd attempt with no reason why.
Make sure you test the user exists then loop the finduser part to get around this.
•
•
Join Date: Dec 2004
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by QKSTechTrainee
Hello - here's my problem - trying to set up a lil bit of code that checks win2k disk quota and warns user if they are approaching their disk space threshold.
here's the code - (cut down for simplicity - this version doesnt really do much but should work)
Dim vol, quotauser
Set vol = CreateObject("Microsoft.DiskQuota.1")
vol.Initialize "C:\", false
quotauser = vol.finduser("insert user name here")
if quotauser.quotaused >= quotauser.threshold then
msgbox("Warning - nearing disk space limit")
end if
ok - so - why won't this work? - on running the script (by double-clicking the .vbs icon on my desktop cos I aint running it over our net til I know it works safely) - I get the following error message from Windows Script Host
Line:4
Char:1
Error: Object doesn't support this property or method
Code: 800A01B6
weird - especially since I found the finduser method of the diskquotacontrol object right there on msdn site - so - anyone got any ideas?
Thanks
quotauser = vol.finduser("insert user name here")
It should read:
set quotauser = vol.finduser("insert user name here")
![]() |
Similar Threads
- Vista displaying false Hard Disk Quota (Windows Vista and Windows 7)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB4 Printer Object or Packing Printlines & BTRIEVE
- Next Thread: how to select folder using commondialog in visual basic
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





