Friday, February 8, 2008

How to Get Free space/Total space of Given Drive using VBScript

Dim a,s,t
Call GetFreeSpace("C:")
Wscript.echo s
Function GetFreeSpace(drvPath)
dim fs, d
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & drvPath & " - "
s = s & d.VolumeName
s = s & " Free Space: " & d.FreeSpace/1024 & " Kbytes"
s = s & " Total Space: " & d.TotalSize/1024 & "Kbytes"
GetFreeSpace = s
'MsgBox s
End function

No comments: