By David Wiseman (Administrator)Created 03 Aug 2008, Modified 08 Nov 2009
My Rating:
Vote
Rating:
(1 votes)
Views:10636
Downloads:1172

Drive Space Report

Language:  HTA

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Yes Windows 2008 Unknown
Description

Display a drive space report for multiple computers. This HTA can check the drives of multiple computers and produce a HTML report that will highlight any drives that are low on free space. The HTA also generates a CSV version of the report.


Notes
The Drive Space Report is a GUI script that allows you to view the disk drives and free space on several computers.  Just enter the computer name or IP Address, one per line and click the "Generate Report" button to display the report.  Click the "Download Report (CSV)" button to save the report in CSV (comma separated) format.

drive space report
 
Code

Line Numbers: On  Off      Plain Text
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
    <title>WiseSoft Drive Space Report</title>
    <hta:application applicationname="WiseSoft Drive Space Report" scroll="yes" singleinstance="yes"
        windowstate="normal">
<style type="text/css">
    body
    {
        background-color: #F2F2F2;
        font: bold 10pt arial,sans-serif;
        color:#787878;
        margin:0px;
    }
    table
    {
        width: 400;
        border: 2px solid;
        border-collapse: collapse;
        border-color: #696969;
    }
    th
    {
        border: 1px dotted #111111;
        border-color: #787878;
        color: #FFFFFF;
        font: bold 12pt arial,sans-serif;
        background-color: #787878;
        text-align: left;
    }
    td
    {
        border: 1px dotted #111111;
        border-color: #787878;
        font: bold 10pt arial,sans-serif;
        color: #787878;
    }
    .neutral
    {
        background-color: #FFFFE0;
        color: #787878;
    }
    .good
    {
        background-color: green;
        color: white;
    }
    .warning
    {
        background-color: yellow;
        color: black;
    }
    .critical
    {
        background-color: red;
        color: black;
    }
    .tableHead td
    {
        padding: 5px;
        font: bold 14pt arial,sans-serif;
        background-color: #787878;
        text-align: center;
        color: white;
    }
    h1
    {
        background-color: #787878;
        color: white;
        font: bold 20pt arial,sans-serif;
        text-align: center;
    }
</style>
</head>

<script language="VBScript">

	Option Explicit
    
    ' ********** Constants **********
    const bytesToMB = 1048576
    const bytesToGB = 1073741824
    const bytesToTB = 1099511627776
	const warningLevel = 20 ' < 20% = warning (yellow)
	const criticalLevel = 10 ' < 10% = critical (red)
	const goodLevel = 50 ' > 50% = good (green)
	' **********************************

	sub GetDriveReportsHTML
		dim html, strComputer,strComputers
		
		strComputers = txtComputers.value
		
		for each strComputer in SPLIT(strComputers,chr(13))
		    strComputer = TRIM(REPLACE(strComputer,chr(10),""))
		    if strComputer <> "" then
			    html = html & GetDriveReportHTML(strComputer)
			end if
		next
		report.InnerHTML = html
	end sub

    function ConvertToDiskUnit(byval value) 
        IF (value/bytesToTb) > 1 THEN
            ConvertToDiskUnit = round(value / bytesToTB,1) & " TB"
        ELSEIF (value/bytesToGb) > 1 THEN
            ConvertToDiskUnit = round(value / bytesToGB,1) & " GB"
        ELSE
            ConvertToDiskUnit = round(value / bytesToMB,1) & " MB"
        END IF
    end function

	function GetDriveReportHTML(byval strComputer)

		Dim objWMIService, objItem, colItems
		Dim strDriveType, strDiskSize, htmlDriveReport

		ON ERROR RESUME NEXT
		Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
		IF Err.Number <> 0 THEN
			GetDriveReportHTML = "<span class=""critical"">Error connecting to '" & strComputer & "'</span><br/><br/>"
			Err.Clear
			ON ERROR GOTO 0
			EXIT FUNCTION
		END IF

		ON ERROR GOTO 0
		Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")

		htmlDriveReport = "<table><tr class=""tableHead""><td colspan=""5"">" & strComputer & _
				"</td></tr><tr><th>Drive</th><th>Size</th><th>Used</th><th>Free</th><th>Free(%)</th></tr>"

		For Each objItem in colItems
	
			DIM pctFreeSpace,strFreeSpace,strusedSpace, cssClass
			pctFreeSpace = round(((objItem.FreeSpace / objItem.Size) * 100),1)
			strDiskSize = ConvertToDiskUnit(objItem.Size) 
			strFreeSpace = ConvertToDiskUnit(objItem.FreeSpace)
			strUsedSpace = ConvertToDiskUnit(objItem.Size-objItem.FreeSpace)

			IF pctFreeSpace < criticalLevel THEN
				cssClass = "critical"
			ELSEIF pctFreeSpace < warningLevel THEN
				cssClass = "warning"
			ELSEIF pctFreeSpace > goodLevel THEN
				cssClass = "good"
			ELSE
				cssClass = "neutral"
			END IF

			dim strChart 
			strChart = "<div style=""width=100%;""><span style=""width=" & 100-pctFreeSpace & _
				"%;background-color:blue;""></span><span style=""width=" & pctFreeSpace & _
				"%;background-color:#FF00FF;""></span></div>"

			htmlDriveReport = htmlDriveReport & "<tr><td>" & objItem.Name & strChart & "</td><td>" & _
					strDiskSize & "</td><td>" & strUsedSpace & "</td><td>" & _
					strFreeSpace & "</td><td class=""" & cssClass & """>" &  pctFreeSpace & "%</td></tr>"

		Next
	
		htmlDriveReport = htmlDriveReport + "</table></br>"

		GetDriveReportHTML =  htmlDriveReport
	
	end function
	
	sub GetDriveReportsCSV
	    dim csv, strComputer,strComputers, path
		
		strComputers = txtComputers.value
		
		csv = "Computer,Drive,Size,Used,Free,Free(%)"
		
		for each strComputer in SPLIT(strComputers,chr(13))
		    strComputer = TRIM(REPLACE(strComputer,chr(10),""))
		    if strComputer <> "" then
		        if csv <> "" then
		            csv = csv & VbCrLf
		        end if
			    csv = csv & GetDriveReportCSV(strComputer)
			end if
		next
	    path = INPUTBOX("Enter FileName:","Enter FileName","MyDriveReport.csv")
	    if path = "" then
	        exit sub
	    end if
	    WriteTextFile csv, path
	 end sub
	
	function GetDriveReportCSV(byval strComputer)

		Dim objWMIService, objItem, colItems
		Dim strDriveType, strDiskSize, csvDriveReport

		ON ERROR RESUME NEXT
		Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
		IF Err.Number <> 0 THEN
			GetDriveReportCSV = strComputer & ",Error,Error,Error,Error,Error"
			Err.Clear
			ON ERROR GOTO 0
			EXIT FUNCTION
		END IF

		ON ERROR GOTO 0
		Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")

		For Each objItem in colItems
	
			DIM pctFreeSpace,strFreeSpace,strusedSpace, cssClass
			pctFreeSpace = round(((objItem.FreeSpace / objItem.Size) * 100),1)
			strDiskSize = ConvertToDiskUnit(objItem.Size) 
			strFreeSpace = ConvertToDiskUnit(objItem.FreeSpace)
			strUsedSpace = ConvertToDiskUnit(objItem.Size-objItem.FreeSpace)

			IF pctFreeSpace < criticalLevel THEN
				cssClass = "critical"
			ELSEIF pctFreeSpace < warningLevel THEN
				cssClass = "warning"
			ELSEIF pctFreeSpace > goodLevel THEN
				cssClass = "good"
			ELSE
				cssClass = "neutral"
			END IF
			
			if csvDriveReport <> "" then 
			    csvDriveReport = csvDriveReport & VbCrLf
			end if

			csvDriveReport = csvDriveReport & strComputer & "," & objItem.Name & "," & _
					strDiskSize & "," & strUsedSpace & "," & _
					strFreeSpace & "," &  pctFreeSpace & "%"

		Next
		
		GetDriveReportCSV =  csvDriveReport

	end function
	
	sub WriteTextFile(byval txt,byval path)
	    DIM objFSO, objTextFile
	        
        set objFSO = createobject("Scripting.FileSystemObject")
        
        IF objFSO.FileExists(path) THEN
            IF msgbox("Warning: file already exists! Overwrite file?",vbYesNo+vbQuestion,"Overwrite File?") = vbNo THEN
                exit sub
            END IF
        END IF

        set objTextFile = objFSO.CreateTextFile(path)

        objTextFile.Write(txt)
        objTextFile.Close
        msgbox "Created '" & path & "' Report",vbOKOnly+vbInformation
	end sub

</script>

<body>
    <h1 style="margin-bottom: 0px;">
        Drive Space Report</h1>
    <div style="text-align: right; font: bold 8pt arial,sans-serif; color: #787878;">
        By David Wiseman, <a target="_blank" href="http://www.wisesoft.co.uk">www.wisesoft.co.uk</a>
     </div><br />
    <div style="text-align: center;">
Enter names of computers (one line per computer):<br />
        <textarea name="txtComputers" rows="4" cols="50">
localhost
.
127.0.0.1
        </textarea><br />
        <input style="font-weight:bold;" onclick="GetDriveReportsHTML" type="submit" value="Generate Report"></input> 
        <input onclick="GetDriveReportsCSV" type="submit" value="Download Report (CSV)"></input>
        <br />
        <br />
    </div>
    <div style="text-align: center;" id="report">
    </div>
</body>
</html> 

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
David Wiseman (Administrator)
United Kingdom
Posted On: 8/7/2008 3:15:02 PM

Just added a chart (progress bar) to show the used disk space.

HYst
Posted On: 9/12/2017 7:52:45 PM

You've got lunch and then study-hall, right? That's two hours. Plentyof time to run down this clue and Ugg Pas Cher Femme get back before asics sko anyone misses us. chaussures nike pas cher I'llget the whole team out. Harajuku Fun Madness is the best Cheap True Religion Jeans game ever made. I know I alreadysaid that, but it bears repeating. It's an ARG, an Alternate Nike Shoes Sale Store Reality Game,and the story Cheap Michael Kors Handbags goes that Yeezy Boost Sale Online a gang of Japanese fashion-teens discovered a mi-raculous healing gem at the temple in Cheap True Religion Jeans Harajuku, which is Christian Louboutin Shoes Outlet basicallywhere cool Japanese teenagers invented every major subculture for Nike Air Jordan 11 thepast ten years. They're being Timberland Outlet hunted by evil monks, the Yakuza Cheap Nike Air Huarache (AKAthe Japanese mafia), aliens, tax-inspectors, parents, and a rogue Uggs For Cheap artificialintelligence. They Billige Nike Sko slip Air Jordan Retro Sale the players coded messages that we have to de-code and use Moncler Jackets Discount Marketplace to track down clues nike air jordan pas cher that lead Adidas Yeezy Cheap to more coded messages andmore Hyperdunk 2014 clues. Imagine Nike Kyrie the best Michael Kors Handbags Discount afternoon you've ever spent prowling the Nike Air 90 streets Coach Bags On Sale of acity, checking out all the Nike Air Max Cheap weird people, funny hand-bills, street-maniacs,and funky shops. Now Cheap Michael Kors Tote Bag add Air Max Sneakers a scavenger hunt to that, It was hard to UGGS Outlet stay cool on the bus. We new yeezy shoes were all a little drunk, andlooking Cheap Toms Shoes Outlet at our faces under the bright bus lights was kind Mens Nike Air Max of hilarious. Wegot pretty loud and the driver used his intercom to tell us to günstige nike schuhe keep pandora outlet store itdown twice, then told us to shut up right now or Coach Outlet Store Online he'd call the cops. That set us Canada Goose Online Store to giggling again and we Nike Air Shoes disembarked Nike Huarache Womens Cheap in a mass before hedid Cheap Nike Huarache call the cops. We were in North Pandora Store Sale Beach now, and there were Nike Air Damen lots ofbuses, taxis, the BART at Market Street, neon-lit clubs coach factory outlet online and cafes The official UGG to pullapart our Stone Island Outlet grouping, so we drifted away. I got home and fired up my Xbox and started typing ugg factory outlet in keys from myphone's screen. It Adidas Superstar Sale Online was dull, Nike Air Max Goedkoop hypnotic work. I was a little drunk, and itlulled me Adidas Neo Discount Sale into a half-sleep.Don't you even read Xnet? It's all over Scarpe Air Max the place. You ever hear of theSpeedwhores? I nearly TOMS For Sale choked. That was Jordan Store Trudy Ugg boots Sale Doo's band — as in Trudy Doo, thewoman who Yeezy Shoes Discount Marketplace had TOMS OUTLET paid me and Jolu to update the indienet code. > Yeah I've heard of them> They're putting on a nfl store huge Uggs Pas Cher Soldes show Chaussure Nike Air Max Pas Cher and they've got nike sneakers like fifty bands signedto play Bottes Ugg Femme Pas Cher the bill, Abercrombie and fitch store going to set Nike Roshe Run Sale up on the tennis courts and bring out theirown amp trucks and Chaussure Nike Pas Cher rock out Jordan Shoes Air all nightI felt Nike Pas Cher Femme like I'd been living Soccer Boots Outlet nike under a rock. How had I missed that? Therewas an anarchist bookstore on Valencia that Ray Ban Sunglasses Online I sometimes passed on theway to school that Doudoune Moncler Femme Pas Cher had a poster of an old revolutionary named EmmaGoldman adidas store with the caption "If canada goose jacket outlet I can't dance, I don't want new jordan releases to be UGG BOOTS FOR WOMEN a part ofyour revolution." I'd been new pandora charms spending all Nike Shox Cheap my energies Moncler Outlet on Air max dam figuring Jordan Shoes For Cheap out howto use the Kobe Shoes Nike Xnet to Nike Factory Outlet organize dedicated fighters so they could jam newest lebron shoes the Pandora Outlet DHS,but this was Michael Kors Outlet so nike schuhe günstig much cooler. A moncler jacket sale big concert — I Discount Air Max had no idea how to doone of those, but I was Yeezy Men glad someone zapatos de futbol nike did. And cheap uggs now that I thought Descuentos Nike of it, I was damned Nike Shoes Online proud Michael Kors Clearance that they were us-ing Nike Soccer Cleats Boots the Xnet to do Nike Free Run 5.0 Womens it. The North Face Outlet next day I was a Adidas Soccer Cleats Cheap zombie. Ange and I had chatted Nike Factory Store — flirted — until4AM. Lucky for Ugg Outlet Online Store me, toms shoes outlet it was a Saturday and I was able to Canada Goose Outlet sleep in, Negozi Pandora but147between the hangover and Official NHL Jerseys the Moncler Sale sleep-dep, I could barely put Cheap Michael Kors twothoughts together. By lunchtime, I managed to get up Nike Store and get my ass out onto the streets. I staggered Official Toms Shoes Outlet down toward the Turk's prada outlet to pandora jewelry store buy my coffee — these days, if Iwas alone, Original Ugg Boots I always Discount TOMS bought my coffee there, like Boost Yeezy Sale On Line the Chaussure Air Max Turk Cheap Louboutin Heels and I were partof Louboutin Wedding Shoes a secret club. On the way, I passed a lot of fresh graffiti. I liked Mission graffiti; a lotof the times, it came scarpe nike in huge, luscious murals, or sarcastic art-studentstencils. I liked that the Mission's taggers kept Nike Air Huarache For Sale right on going, under thenose of the DHS. Cheap Toms Outlet Store Another chaussure basket homme kind Nike Roshe Run of Xnet, I supposed Air Max Kopen — they must converse store have allkinds of ways of knowing what was going on, where to get paint, Adidas Superstar whatcameras Pandora Official Website worked. Some Air Max Femme of the cameras had nike shoes been spray-painted over, Inoticed. Maybe they Canada Goose Outlet used Xnet! Painted in ten-foot-high letters on the Jordan Sneakers For Sale side of an auto-yard's Canada Goose Womens Coats fence Moncler Outlet Online werethe drippy words: DON'T TRUST ANYONE Canada goose dam OVER 25. I Ugg Pas Cher En France stopped. Adidas Originals Stan Smith Had botas de futbol someone left my "party" last night and come here witha can of paint? Zapatillas Air Max A lot of Nike Shox discount Sale those fitflops sale uk people lived in the Air Max 90 neighborhood. I got my ?????? ????? coffee Boutique Ugg and had a nike tn pas cher little Zapatillas Nike Air Max Baratas wander around town. Air max levne I kept longchamp bags on sale thinking Ishould be calling someone, seeing if they Toms Outlet Online wanted to get a ugg clearance movie Hugo Boss Sale orsomething. That's how it used Air Max Pas Cher to be Christian Louboutin Heels on a lazy Saturday like this. But whowas I going to call? Pandora Store Van Nike Air Pas Cher wasn't talking to Nike Outlet Store me, Discount Christian Louboutin Shoes I didn't think I was Nike Outlet readyto talk to Jolu, Nike Air Women and Darryl —Well, I nike mercurial soccer cleats couldn't Pandora Style Beads call Darryl. I got my coffee and went cheap uggs for women home and did a little searching Discount Ray Ban Sunglasses around onthe Xnet's blogs. These anonablogs christian louboutin outlet were untraceable Nike Tn Requin Pas Cher to Adidas Yeezy Boost 350 For Sale any author —unless that author Vans Black Sneakers was stupid enough to put her name on it — nike sb stefan janoski and therewere a lot of them. Adidas Shoes Discount Marketplace Most of them Michael Kors were apolitical, but a lot cheap nike air max of themweren't. Nike Air Sneakers They talked about schools and Adidas Originals Superstar the unfairness New Air Max 2017 there. They talkedabout the cops. TOMS STORE Tagging. Turned Scarpe Nike Scontate out there'd been New Nike Shoes plans zapatillas nike baratas for the Air Nike concert Cheap Air Max in the Doudoune Moncler Site Officiel park for weeks. Cheap Real Jordans Ithad hopped from blog to blog, turning into a full-blown Adidas NMD For Sale movementwithout my noticing. And the concert was called ugg store Don't Trust AnyoneOver 25. Well, that explained where adidas outlet Ange pandora beads got it. It was a good slogan. 148Monday morning, I Cheap Nike Free Run decided Moncler Outlet Store I wanted to check out that anarchist book-store again, see vans shoe store about getting one of those Emma Goldman canada goose jackets on sale posters. suivre un envoi Ineeded Nike Shoes Discount Marketplace the reminder. I detoured Doudoune Moncler Pas Cher down to ????? ????? 16th and Mission on my way to school, then up toValencia and across. The store was shut, Nike Online Store but I Nike joggesko got the hours off the doorand made sure they still had Reebok Outlet Store that poster up.As I walked air force one pas cher down Valencia, I was amazed to see how much of theDON'T TRUST ANYONE OVER 25 stuff Nike Air Max Sale there was. Half the shops hadDON'T Cheap Retro Jordans For Sale TRUST merch in the Adidas Originals Sale windows: lunchboxes, babydoll TOMS SHOES OUTLET tees, pencil-boxes, trucker hats. The hipster stores have womens nike air max been getting 23 IS BACK Store faster ADIDAS NMD SALE ON LINE and faster,of Cheap Air Max Trainers course. As new louboutin heels memes sweep the net in the course Hogan Outlet of a day or two,stores have gotten better at putting merch in the windows to match. Some funny little youtube of a guy launching himself with jet-packsmade of carbonated water would land in your inbox on Monday Nike Polo Sale and byTuesday you'd be able to buy t-shirts with stills from the nike air video Boty Nike Air on it. But it was reebok running shoes amazing to see something make Yeezy Black the chaussure adidas pas cher leap huarache sneakers from retro jordans for cheap Xnet to thehead shops. Distressed nike sportschuhe designer jeans nike jordan shoes with the Toms Factory Outlet slogan written in carefulhigh school ball-point ink. Embroidered patches. Good Pandora Store news travels fast.