I have a vbs script  here that sets the pagefile size to1.5x the size of RAM. Any ideas on how I can only make it execute if the hard drive as enough space for it? My fantasy would be like if "Hard drive free space is greater than 4x the ram size., execute".

 

Option Explicit

'Subroutine; Page File configuration
Sub ConfigPageFile
    Dim strComputer, objWMIService, objSWbemServices, colPageFile, colSWbemObject
    Dim colSWbemObjectSet, objSWbemObject, objPageFile, SystemRAM
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)
    Set colPageFile = objWMIService.ExecQuery ("SELECT * FROM Win32_PageFileSetting")
    Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")
    For Each objSWbemObject In colSWbemObjectSet
        SystemRAM = objSWbemObject.TotalPhysicalMemory / 1024
    Next
    For Each objPageFile In colPageFile
        objPageFile.InitialSize = 1.5 * SystemRAM
        objPageFile.MaximumSize = 1.5 * SystemRAM
        objPageFile.Put_
    Next
End Sub

ConfigPageFile



[edited by: aabbasi at 11:20 PM (GMT -7) on 8-2-2011] typo