Thursday, March 3, 2011

Script to view disk free space


The below simple VB Script to show the free disk space in the local computer, copy the below code and paste to notepad and save it as .vbs extension.

Const HDD = 3
 strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = " & HDD & "")
 For Each objDisk in colDisks
    Wscript.Echo "Drive: "& vbTab &  objDisk.DeviceID & vbTab & objDisk.FreeSpace      
   Next

No comments:

Web Hosting