This script will put a txt file on your Desktop with a list of free space on your drivers. (VBScript)

'Logs the free hard disk space info to a log file.

Message = "This script will write a file (FreeSpace.txt) on your Desktop." & vbCr
Message = Message & "You can open the file with Nodepad." & vbCr & vbCr
Message = Message & "Continue?"

X = MsgBox(Message, vbYesNo + vbQuestion, "Paul's XP and Vista Tweaks")
If X = 6 Then

Dim iSpc, strComputer, objWMIService
Dim fso, fsHandle, MyShell,LogFileName, colItems, objItem
Set MyShell = CreateObject("Wscript.Shell")
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
LogFileName= MyShell.SpecialFolders("Desktop") & "\FreeSpace.txt"
set fsHandle = fso.OpenTextFile (LogFileName,8,True)
fsHandle.Writeline ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") fsHandle.Writeline ("This is a list of free space on your harddrives")
fsHandle.Writeline ("Visit www.paulsxp.com")
fsHandle.Writeline ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
fsHandle.Writeline Date
fsHandle.Writeline Time
fsHandle.Writeline ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
strComputer = "."
Set objWMIService = GetObject _
( "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 3")

For Each objItem in colItems
'Retrieve free space & convert from uint64
iSpc = cDbl(objItem.FreeSpace)
fsHandle.Writeline objItem.DeviceID & " - " _
& FormatiSpc(iSpc) & " GB free"
Next

Function FormatiSpc(intSpace)
intSpace = intSpace/1024
intSpace = intSpace/1024
intSpace = intSpace/1024
intSpace= FormatNumber(intSpace,1)
FormatiSpc = intSpace
end function

fsHandle.Writeline ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
fsHandle.Writeblanklines 2
fsHandle.close
set MyShell = Nothing
set fso = Nothing
Title = "The file FreeSpace.txt is now on your Desktop." & vbCr
Title = Title & "Ths script was downloaded from www.paulsxp.com."
MyBox = MsgBox(Title,64,"Finished")
End If

Download


Back to Line 29