Hard disks with capacities measured in the hundreds
of gigabytes are commonplace even in low-end systems nowadays, so disk
space is much less of a problem than it used to be. However, remember
that Windows Home Server has a system partition—drive C:—and that volume
comes with a fixed 60GB size. With Windows Home Server taking up about
10- to 16GB (depending on the size of the paging file), you only have so
much space left over to install other programs or store data in the
Administrator account’s local folders. Therefore, it’s a good idea to
keep track of how much free space you have on drive C:.
One way to check disk free space is to select Start,
Computer. The Tiles view (select View, Tiles to see it) tells you the
free space and the total size and displays the used portion of the disk
in a graph, as shown in Figure 1.
Alternatively, right-click drive C: in Windows Explorer and then click
Properties. The system partition’s total capacity, as well as its
current used and free space, appear in the General tab of the property
sheet, as shown in Figure 2.
Listing 1 presents a VBScript procedure that displays the status and free space for each drive on your system.
Listing 1. A VBScript Example That Displays the Status and Free Space for the System Drive (C:)
Option Explicit
Dim objFSO, strMessage
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Start the display string
strMessage = "Status Report for Drive C" & vbCrLf & vbCrLf
' Get the properties of drive C
With objFSO.Drives("C")
' Add the volume name to the message
strMessage = strMessage & "Volume Name: " & .VolumeName & vbCrLf
' Check the drive status
If .IsReady = True Then
' If it's ready, add the status, total size,
' and the free space to the message
strMessage = strMessage & "Status: Ready" & vbCrLf
strMessage = strMessage & "Total space: " & _
FormatNumber(.TotalSize / 1073741824, 2) & " GB" & vbCrLf
strMessage = strMessage & "Free space: " & _
FormatNumber(.FreeSpace / 1073741824, 2) & " GB"
strMessage = strMessage & vbCrLf & vbCrLf
Else
' Otherwise, just add the status to the message
strMessage = strMessage & "Status: Not Ready" & vbCrLf & vbCrLf
End If
End With
' Display the message
WScript.Echo strMessage
|
This script creates a FileSystemObject and then uses its Drives collection to return a reference to the system drive: Drives("C"). Then the script checks the Drive object’s IsReady property. If the drive is available (there’s no reason why it wouldn’t be, but you never know), a series of property values is added to the message: VolumeName, TotalSize, and FreeSpace.
(Note that the last two are converted from bytes to gigabytes by
dividing the property value by 1,073,741,824.) The script finishes by
displaying the drive data, as shown in Figure 3.