Feoh
-
Total Posts
:
10
- Scores: 0
-
Reward points
:
0
- Joined: 7/7/2009
- Location: Somerville, Massachusetts
-
Status: offline
|
Check for at least N bytes available in system %TEMP% folder
Tuesday, July 07, 2009 8:46 AM
( permalink)
This might be too trivial to post, but perhaps I can save somebody some WMI research. Also please let me know if you think there are easier ways to do what I'm doing here. --
' Check that this system has at least minRequiredSpace bytes free in its %TEMP% folder.
Function CheckSystemTempSpace(minRequiredSpace)
Dim fileSys, tempFolder, tempFSO, tempDrive, objWMIService, colItems, objItem, strComputer,hasSpace, retVal
minRequiredSpace = CCur(minRequiredSpace)
' MsgBox "Required Space: " & minRequiredSpace
Set fileSys = CreateObject("Scripting.fileSystemObject")
Set tempFolderPath = fileSys.GetSpecialFolder(2)
Set tempFolder = fileSys.GetFolder(tempFolderPath)
strComputer = "."
tempDrive = tempFolder.Drive
' MsgBox "The path to your Temp folder is: '" & tempFolderPath & "'."
' MsgBox "The drive your temp folder is on is:" & tempDrive
' WMI connection to Root CIM
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(_
"Select * from Win32_LogicalDisk where Caption='" & tempDrive & "'")
' We should only get one item in the response
For Each objItem in colItems
'Wscript.Echo "Caption: " & objItem.Caption & VbCr &"FreeSpace: " & objItem.FreeSpace
hasSpace = CCur(objItem.FreeSpace)
' MsgBox "Has Free Space: " & hasSpace
Next
CheckSystemTempSpace = hasSpace > minRequiredSpace
End Function
|
|
|
|