Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: VB Script to Get Free Space On a Drive

VB Script to Get Free Space On a Drive


Option Explicit

Dim FsoObject, DiskDrive, AvailSpace

' Instantiate the VBScript FileSystemObject
Set FsoObject = WScript.CreateObject("Scripting.FileSystemObject")

' Use the FilesystemObject Object's GetDrive Method to set up a reference to the computer's
' C: Drive.
Set DiskDrive = FsoObject.GetDrive(FsoObject.GetDriveName("C:"))

' Main Processing Section

' Use the FileSystemObjects FreeSpace Property to Determine the Amount of FreeSpace in MB
' on the C: Drive

AvailSpace = ((DiskDrive.FreeSpace / 1024) / 1024) / 1024

' Use VBScripts FormatNumber Function to format the results as a Whole Number
AvailSpace = FormatNumber(AvailSpace, 0)

' Display the Amount of Free Space on the C: Drive
WScript.Echo "There is Currently: " & AvailSpace & " GB available on the C: Drive"


How helpful was this article to you?

Related Articles

article VBS Script To Send All AD Domain Controllers Disk Space Information To Excel
This VBS script will write all the Active...

(No rating)  4-21-2008    Views: 177   
article How to Hide drive letters in My Computer in XP
Have you

(No rating)  4-5-2008    Views: 139   
article How do I format a NTFS, FAT/FAT32 drive with XP installed?
Identify the file system that you are...

(No rating)  3-10-2008    Views: 153   

User Comments

Add Comment
No comments have been posted.