Right Click Tools - Cache Size
Main Menu
>
Tools
>
Right Click Tools
Cache Size
Right click on a computer or a collection and change the cache size.
Download
Code
-----------Single computer--------changecache-Comp.vbs------------------- On Error Resume Next '**************************************************************** ' Change client Cache ' Changecache [computer name] [Cache size in MB] ' Created by Matthew '**************************************************************** 'if no computer name is given then it will just exit 'if no cache size if given then it will prompt for a size in MB 'a slient failure will occur if the machine is not reachable ComputerName = wscript.arguments.item(0) ' computer name CacheSize = wscript.arguments.item(1) ' cache size in Mbs if len(ComputerName)=0 then wscript.quit end if if len(CacheSize)=0 then CacheSize =InputBox("Cache size in MBs:") if CacheSize < 0 or Cachesize > 118378 then ' 118378 max cache size allowed 'if the user enters nothing or a alpha character then default to 2GB CacheSize =2000 end if end if VbsFile= "\\" & ComputerName & "\admin$\changecache.vbs" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile(VbsFile) if Err.Number=76 then Err.Clear ' Clear the error and exit wscript.quit end if objFile.WriteLine("Dim oUIResource") objFile.WriteLine("Dim oCache") objFile.WriteLine("Set oUIResource = CreateObject("& chr(34) &"UIResource.UIResourceMgr"& chr(34) &")") objFile.WriteLine("Set objCacheInfo = oUIResource.GetCacheInfo") objFile.WriteLine("objCacheInfo.TotalSize = " & CacheSize ) objFile.WriteLine("Set oUIResource = Nothing") objFile.WriteLine("Set objCacheInfo = Nothing") objFile.Close set objFile = nothing 'now run the file, a slient failure will occur if the machine is not reachable '''''''''''''''''''''''''''strCommand = "cscript " & VbsFile strCommand = "wscript " & VbsFile Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & ComputerName & "\root\cimv2") Set objStartup = objWMIService.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.ShowWindow = SW_NORMAL Set objProcess = objWMIService.Get("Win32_Process") intReturn = objProcess.Create (strCommand, Null, objConfig, intProcessID) WScript.Quit /////////////////////cache-comp.Xml///////////////////////////////////
cscript changecache-Comp.vbs
##SUB:Name##
/////////////////////////////////////////////////////////////////////////// ----------------------------------------------------- -----------Collection of computers--------changecache-Coll.vbs------------------- On Error Resume Next '**************************************************************** ' Change client Cache ' Changecache [Collection ID] [Cache size in MB] ' Created by Matthew '**************************************************************** 'if no computer name is given then it will just exit 'if no cache size if given then it will prompt for a size in MB 'a slient failure will occur if the machine is not reachable 'Get the variables..... SMSCollectionID= wscript.arguments.item(0) ' Collection ID CacheSize = wscript.arguments.item(1) ' cache size in Mbs if len(SMSCollectionID)=0 then wscript.quit end if 'Get the cache size... if len(CacheSize)=0 then CacheSize =InputBox("Cache size in MBs:") if CacheSize < 0 or Cachesize > 118378 then ' 118378 max cache size allowed 'if the user enters nothing or a alpha character then default to 2GB CacheSize =2000 end if end if 'we are looking at multiple computers loop strQuery = "select * from SMS_CM_RES_COLL_" & SMSCollectionID Set Computers= SWbemServices.ExecQuery(strQuery) for each Computer in Computers GetComputers(Computer) Next WScript.Quit ''''''''''''''''''''''''''''''''''''''''''''''''''' sub GetComputers(ComputerName) VbsFile= "\\" & ComputerName & "\admin$\changecache.vbs" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile(VbsFile) if Err.Number=76 then Err.Clear ' Clear the error and exit wscript.quit end if objFile.WriteLine("Dim oUIResource") objFile.WriteLine("Dim oCache") objFile.WriteLine("Set oUIResource = CreateObject("& chr(34) &"UIResource.UIResourceMgr"& chr(34) &")") objFile.WriteLine("Set objCacheInfo = oUIResource.GetCacheInfo") objFile.WriteLine("objCacheInfo.TotalSize = " & CacheSize ) objFile.WriteLine("Set oUIResource = Nothing") objFile.WriteLine("Set objCacheInfo = Nothing") objFile.Close set objFile = nothing 'now run the file, a slient failure will occur if the machine is not reachable ''''''''''''''''''''''''''' strCommand = "wscript " & VbsFile Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & ComputerName & "\root\cimv2") Set objStartup = objWMIService.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.ShowWindow = SW_NORMAL Set objProcess = objWMIService.Get("Win32_Process") intReturn = objProcess.Create (strCommand, Null, objConfig, intProcessID) end sub ----------------------------------------------------------------- ///////////////////cache-col.Xml////////////////////////////////////
changecache-Coll.vbs
##SUB:CollectionID##
/////////////////////////////////////////////////////// ----------------------------------------------------
Documentation
Unlike other tools this doesn't copy a fle to the machine and then run it. It will create the file on the computer and then run it. This cuts down on the number of files necessary to use a tool. Copy cache-comp.Xml to x:\Program Files\Microsoft Configuration Manager\AdminUI\XmlStorage\Extensions\Actions\7ba8bf44-2344-4035-bdb4-16630291dcf6 modify the xml file to point to changecache-Comp.vbs copy cache-col.Xml to x:\Program Files\Microsoft Configuration Manager\AdminUI\XmlStorage\Extensions\Actions\dbb315c3-1d8b-4e6a-a7b1-db8246890f59 x:\Program Files\Microsoft Configuration Manager\AdminUI\XmlStorage\Extensions\Actions\fa922e1a-6add-477f-b70e-9a164f3b11a2 modify the xml file to point to changecache-Coll.vbs This have been tested on the site server not on a remote console --Created by: Matthew Hudson