|
MRIS -> UNC Path Free Space Check (8.Jul.2008 2:13:08 AM)
|
Here is my community contribution that performs a freespace check on a UNC path. Hopefully somebody will find this useful, especially for checking free disk space on things like NAS units.
' /////////////////////////////////////////////////////////////////////////////
' Accepts 2 parameters
' First parameter is the UNC path as a string, eg "\\server\path"
' Second parameter is the number of MB to check
' the check reports success of MB free is above this number
'
' /////////////////////////////////////////////////////////////////////////////
Option Explicit
' Note: A Monitor function can return True, False or Unknown
' True and False are already defined by Visual Basic Engine
' Define the Unknown return value. This value can be any value > 0
Const retvalUnknown = 1
Function UNCpathDiskSpace(ThePath,Size)
' This file designed, created, tested and deployed by MRIS
On Error Resume Next
Dim fso, d, s, freespace
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(ThePath))
s = "Drive " & ThePath & " - "
s = s & d.VolumeName & " - "
s = s & "Free Space: " & FormatNumber(d.FreeSpace/1048576, 0)
s = s & " MB"
freespace = d.FreeSpace/1048576
If freespace >= Size then
EXPLANATION = s & " > " & FormatNumber(Size,0) & " MB"
UNCpathDiskSpace = True
End If
If freespace < Size then
EXPLANATION = s & " < " & FormatNumber(Size,0) & " MB"
UNCpathDiskSpace = False
End If
End Function
|
|
|
|