Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drive Space & Free Space

Status
Not open for further replies.

ic1frosty

Technical User
May 25, 2003
37
GB

Can anyone help me with the code to output
drive capacities and free space on remote servers to a text file or excel worksheet.
 
Some googling came up with this little snippet:
Issues an alert if free disk space for any hard drive on a computer falls below 100 megabytes.
Code:
Const LOCAL_HARD_DISK = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colMonitoredDisks = objWMIService.ExecNotificationQuery _
    ("Select * from __instancemodificationevent within 30 where " _
        & "TargetInstance isa 'Win32_LogicalDisk'")
i = 0

Do While i = 0
    Set objDiskChange = colMonitoredDisks.NextEvent
    If objDiskChange.TargetInstance.DriveType = LOCAL_HARD_DISK Then
        If objDiskChange.TargetInstance.Size < 100000000 Then
            Wscript.Echo "Hard disk space is below 100000000 bytes."
        End If
    End If
Loop

Source: Microsoft TechNet

;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Private Sub Command3_Click()

Dim curSize As Currency, Free As Currency
With CreateObject("Scripting.FileSystemObject").Drives("C:\")
curSize = .TotalSize
curFree = .FreeSpace
End With
MsgBox "Total " & curSize & " bytes" & vbCrLf & "Free " & curFree & " bytes"

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top