Home > Enterprise Desktop Tips > > Use VBScript to monitor drive space
Enterprise Desktop Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 


Use VBScript to monitor drive space


mike douglas
02.18.2005
Rating: -5.00- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This tip was submitted to the SearchWinSystems.com tip exchange by member Mike Douglas. Please let other users know how useful it is by rating it below.


By using this script (possibly as a scheduled job), free space on systems or shares can be monitored and reported on via e-mail. It's usually a better idea to let your system inform you of space outages rather than your users.


'** DRIVEMON.VBS
  '**
  '** Basic drive usage monitoring script
  '** Usage:  cscript drivemon.vbs <TO: email> <FROM: email> 
<path1> <path2> <path3>... Dim fso, drv, s, drvPath, bBAD on error resume next bBAD = False Set objArgs = WScript.Arguments if (objArgs.Count > 2) then For i = 2 to objArgs.count - 1 drvPath = objArgs(i) Set fso = CreateObject("Scripting.FileSystemObject") Set drv = fso.GetDrive(fso.GetDriveName(drvPath)) eText = Err.Description if i < 1 then s = "Drive " & UCase(drvPath) & " - " else s = s & "Drive " & UCase(drvPath) & " - " end if s = s & drv.VolumeName s = s & vbcrlf x=int(drv.Freespace) y=int(drv.totalsize * .1) if eText > "" then s = s & eText & vbcrlf & vbcrlf eText = "" bBAD = True end if if x < y then s = s & "*** SPACE USAGE ALERT ***" & vbcrlf bBAD = True s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0) s = s & " Kb" & vbcrlf s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0) s = s & " Kb" & vbcrlf & vbcrlf end if Next if bBAD then Set oEmail = CreateObject("CDO.Message") oEmail.From = objArgs(1) oEmail.To = objArgs(0) oEmail.Subject = "WARNING! Drive Monitor Report - " & now() oEmail.TextBody = s oEmail.Send Set oEmail = Nothing end if else wscript.echo "DriveMon.vbs - Email a report of drive usage on any accessible path." & vbcrlf & vbcrlf & "Usage: cscript drivemon.vbs <TO: email> <FROM: email>
<path1> <path2> <path3>..." end if

Do you have comments on this tip? Let us know.

Rate this Tip
To rate tips, you must be a member of SearchEnterpriseDesktop.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Windows legacy operating system management
Windows 2000 batch file command reference
Using CMD.exe and Command.com
Microsoft's Allchin to retire in 2006
Freeware tool purges empty directories
Transplant user profile folders during upgrades
Use 'Clonepr' to move users between AD forests
Establishing a TCP/IP connection between a Win2k app and a mainframe app
Change a local admin password with Local Security Utility.exe
Windows Server 2003 management tools: Remote Desktop for Administration
Boost performance: change Group Policy refresh interval

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Error messages for Windows 2000  (SearchEnterpriseDesktop.com)
IO.SYS  (SearchEnterpriseDesktop.com)
MS-DOS  (SearchEnterpriseDesktop.com)
W2K  (SearchEnterpriseDesktop.com)
Windows 2000  (SearchEnterpriseDesktop.com)
Windows 98  (SearchEnterpriseDesktop.com)
Windows XP  (SearchEnterpriseDesktop.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Enterprise Desktop Security - Virus Protection, Malware Protection, Intrusion Detection
HomeTopicsITKnowledge ExchangeTipsMultimediaWhite PapersBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts