I have scripted FreeSpace.vbs to retrieve the freespace on each of my hard drives.
If you just want to display the information, open a CMD.EXE prompt and type:
cscript //nologo <FolderPath>\FreeSpace.vbs
You will receive a display like the following, where the free space is in megabytes.
C: 15345
D: 31329
If you wanted to process the results in a batch file:
for /f "Tokens=1*" %%a in ('cscript //nologo <FolderPath>\FreeSpace.vbs') do ( set drive=%%a set /a freespace=%%b ... ... )FreeSpace.vbs contains:
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "\{impersonationLevel=impersonate\}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk Where DriveType = 3") For Each objDisk in colDisks Wscript.Echo objDisk.DeviceID & " " _ & Int (objDisk.FreeSpace / 1024 / 1024) Next
0 comments
Hide comments