'Logs the free hard disk space info to a log file.
On Error Resume Next
Message = "This script will write a file (FreeSpace.txt) on your Desktop." & vbCr _
 & "You can open the file with Nodepad." & vbCr & vbCr _
 & "Continue?"

X = MsgBox(Message, vbYesNo + vbInformation, "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 _
 & "Ths script was downloaded from www.paulsxp.com."
MyBox = MsgBox(Title,64,"Finished")
End If