- Vista's Stability Improvements
- Checking Your Hard Disk for Errors
- Checking Free Disk Space
- Deleting Unnecessary Files
- Defragmenting Your Hard Disk
- Setting System Restore Points
- Backing Up Your Files
- Checking for Updates and Security Patches
- Reviewing Event Viewer Logs
- Setting Up a 10-Step Maintenance Schedule
- From Here
Checking Free Disk Space
Hard disks with capacities measured in the tens of gigabytes are commonplace even in low-end systems nowadays, so disk space is much less of a problem than it used to be. Still, you need to keep track of how much free space you have on your disk drives, particularly the %SystemDrive%, which usually stores the virtual memory page file.
One way to check disk free space is to view the Computer folder using either the Tiles view—which includes the free space and total disk space with each drive icon—or the Details view—which includes columns for Total Size and Free Space, as shown in Figure 15.4. Alternatively, right-click the drive in Windows Explorer and then click Properties. The disk's total capacity, as well as its current used and free space, appear in the General tab of the disk's properties sheet.
Figure 15.4 Display the Computer folder in Details view to see the total size and free space on your system's disks.
Listing 15.1 presents a VBScript procedure that displays the status and free space for each drive on your system.
Example 15.1. A VBScript Example That Displays the Status and Free Space for Your System's Drives
Option Explicit Dim objFSO, colDiskDrives, objDiskDrive, strMessage ' Create the File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") ' Get the collection of disk drives Set colDiskDrives = objFSO.Drives ' Run through the collection strMessage = "Disk Drive Status Report" & vbCrLf & vbCrLf For Each objDiskDrive in colDiskDrives ' Add the drive letter to the message strMessage = strMessage & "Drive: " & objDiskDrive.DriveLetter & vbCrLf ' Check the drive status If objDiskDrive.IsReady = True Then ' If it's ready, add the status and the free space to the message strMessage = strMessage & "Status: Ready" & vbCrLf strMessage = strMessage & "Free space: " & objDiskDrive.FreeSpace strMessage = strMessage & vbCrLf & vbCrLf Else ' Otherwise, just add the status to the message strMessage = strMessage & "Status: Not Ready" & vbCrLf & vbCrLf End If Next ' Display the message Wscript.Echo strMessage
This script creates a FileSystemObject and then uses its Drives property to return the system's collection of disk drives. Then a For Each...Next loop runs through the collection, gathering the drive letter, the status, and, if the disk is ready, the free space. It then displays the drive data as shown in Figure 15.5.
Figure 15.5 The script displays the status and free space for each drive on your system.