We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


script to change client cache location using pcs from a csv

ntr2def asked
Medium Priority
Last Modified: 2012-05-11
I'm trying to see if anyone knows of a script that i can run remotely to change the cache path location on a remote client but importing a list of workstations. I can use client center to do one machine at a time but i would rather say import list then change path to c:\software. any ideas?
Watch Question


thats good info but im asking for help so if you can give me something in a form that shows an import of a csv or txt file encompassing together with changing the path of the sms cache location would be most helpful.
The script is not based on WMI so it cannot be executed from Remote.
Why do you want to execute the script remotely if you have SCCM to deploy the script to each client?!


we have software in place that blocks scripts like psexec from being run and software installation from being run from a network resource. It can only be run from a certain directory unfortunately when the client was installed it had its default settings. now in our current environment i need change the temp prgram directory to that "safe" directory. But since psexec isnt allowed to be run and also in using SCCM Client Center i can do one machine at a time, so I believe its using a WMI script and I want somthing that will allow a list import from a csv or txt file.
When using SCCM you can make sure a vbScript get's executed from the local computer e.g. C:\windows\system32\ccm\cache.
Also you could start a copy job into the "secure directory" and then start the script


i know I can do a copy but the problem is since the ccm\cache is not the "secure directory" the copy will be blocked.
huh? So SCCM will never work or?


so we have a test envrionment taht replicates our prod environment. If I use SCCM Client Center and say type in testMachine02 it will connect I will then click "Agent Actions">Select Cache Path. In the Cache Path I can type the path and save. Ok not a big deal  but trying to this for say 200 machines is not something I want to take the time to do. I'm hoping There is a script taht will enumerate what the SCCM Client Center is doing but instead of doing one machine I can feed a list of machines.
ok, your right. Roger Zander has included that in Client Center. So it should be possible via WMI...and it is.
I again did some research and found the WMI Class root/ccm/SoftMgmtAgent

Look here
I've changed the Script so that it will loop throught all Clients which are defined within a textfile and change the Cache then....
intCacheSize = "5000"

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFile = objFSO.OpenTextFile("C:\ComputerList.txt")

Do While Not objFile.AtEndOfStream 
 	strCurrentPC = objFile.ReadLine 
	Set objWMIService = GetObject("winmgmts://" & strCurrentPC & "/root/ccm/SoftMgmtAgent")
	Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
	For Each objItem in colItems
		objItem.Size = intCacheSize
		objItem.Put_ 0
		Wscript.Echo "The Cache On " & UCase(strCurrentPC) & " Located At: " & objItem.Location & " Will Be Changed To: " & objItem.Size & " MB"
	Set objWMIService = GetObject("winmgmts:\\" & strCurrentPC & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'CCMExec'")
	For Each objItem in colItems
		Wscript.Sleep 10000
	WScript.Echo "Done"


Open in new window

AddOn: Did not try it - So please give Feedback if there are some Errors.
AddOn2: If a Client is not reachable (off, firewall,...) the script will fail so you should build in some Error handling and maybe log fhe results into a file


just to clarify im working the actualy client cache location not the cache size does this script result in that? from skimming through it, it looks like its only affecting the client cache size
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.