'DriveInfo.vbs - Show information for local & network drives. 'Note: A bug in WScript results in sizes over 2 GB being misreported. '© Bill James - billjames.geo@yahoo.com - rev 16 Feb 2000 Option Explicit Dim WshShell,FSO,Drv,Dtype,Dfree,Dtot Dim Dname,Dpct,Dused,Dserial,Dinfo Set WshShell=WScript.CreateObject("WScript.Shell") Set FSO=CreateObject("Scripting.FileSystemObject") For each Drv in FSO.Drives If Drv.DriveType=0 Then Dtype="Unknown " If Drv.DriveType=1 Then Dtype="Removable" If Drv.DriveType=2 Then Dtype="Fixed " If Drv.DriveType=3 Then Dtype="Network " If Drv.DriveType=4 Then Dtype="CD-ROM " If Drv.DriveType=5 Then Dtype="RAM Disk " If Drv.IsReady Then If Drv.DriveType=4 Then Dfree="N/A" ElseIf Drv.FreeSpace<1024^2 Then Dfree=FormatNumber(Drv.FreeSpace/1024,0)&" KB" ElseIf Drv.FreeSpace<10240^2 Then Dfree=FormatNumber(Drv.FreeSpace/(1024^2),2)&" MB" Else Dfree=FormatNumber(Drv.FreeSpace/(1024^2),0)&" MB" End If If Drv.TotalSize<1024^2 Then Dtot=FormatNumber(Drv.TotalSize/1024,0)&" KB" ElseIf Drv.TotalSize<10240^2 Then Dtot=FormatNumber(Drv.TotalSize/(1024^2),2)&" MB" Else Dtot=FormatNumber(Drv.TotalSize/(1024^2),0)&" MB" End If If Drv.VolumeName="" Then Dname="(None)" Else Dname=Drv.VolumeName End If Dused=Drv.TotalSize-Drv.FreeSpace If Dused<1024^2 Then Dused=FormatNumber(Dused/1024,0)&" KB" ElseIf Dused<10240^2 Then Dused=FormatNumber(Dused/(1024^2),2)&" MB" Else Dused=FormatNumber(Dused/(1024^2),0)&" MB" End If If Drv.DriveType=4 Then Dpct="N/A" Else Dpct=FormatPercent(Drv.FreeSpace/Drv.TotalSize,1) End If If Drv.DriveType=5 Then Dserial="N/A" Else Dserial=Hex(Drv.SerialNumber) End If Dinfo=Dinfo&"Drive "&Drv.DriveLetter&_ ":"&vbTab&vbTab&vbTab&_ "Drive Type: "&Dtype&vbTab&_ "File System: "&Drv.FileSystem&vbCRLF&_ "Total Size: "&Dtot&vbTab&_ "Free Space: "&Dfree&vbTab&_ "Volume Label: "&Dname&vbCRLF&_ "Used Space: "&Dused&vbTab&_ "Percent Free: "&Dpct&vbTab&_ "Serial Number: "&Dserial&vbCRLF&vbCRLF Else Dinfo=Dinfo&"Drive "&Drv.DriveLetter&_ ":"&vbTab&vbTab&vbTab&_ "Drive Type: "&Dtype&vbTab&_ "(No Media in Drive)"&vbCRLF&vbCRLF End If Next WshShell.popup "Note: A bug in WScript results in " & _ "sizes over 2 GB being misreported." & vbcrlf & _ vbcrlf & Dinfo,,"Information on Available Drives",0
Last Updated on September 2, 2019