Check for at least N bytes available in system %TEMP% folder

Author Message
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)
0
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
 
 

 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9