Eswar Koneti's Blog

All about Configmgr and its connected objects…….

  • About Author
      View eswar koneti's LinkedIn profile
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 95 other subscribers

  • Awards


  • FaceBook Updates

  • Catagories

  • Meta

  • Copyright!

    All the blog posts in this website are owned by Eswar Koneti and may not be reused in any mode without prior approval of Eswar Koneti. You may quote one paragraph from the blog posts if you link to the original blog post.
    Happy Reading!

VB Script to delete Software update files from SCCM client Cache folder

Posted by Eswar Koneti on 26th May 2012

 

Question from Community : When client downloaded a package into the cache and is removed from the collection with the advertisement will the content stay in the cache? Then if you put the client back into the collection later will it download the package or will is run from the cache if the content stays?

Configuration manager will not clean up the content from the cache, files will be available and usable. Content is not specific to any advertisements OR collection memberships. Clients simply require the content and a version of that content; if it’s already in the client cache, it just uses it else it will download and run.

For more information about how sccm client cache works refer http://support.microsoft.com/kb/839513

Here is the script (from Shane Alexander) with little changes that works on both X86 and X64 OS looks into cache folder with folder name like x-x-x-x.1.System (X is random digits) and pipes the folder names to cache.txt file and remove each folder by reading one by one.

On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
‘Delete all software update caches
If objFSO.FolderExists("C:\Windows\System32\ccm\cache") Then
    objShell.Run ("cmd /c dir /b c:\windows\system32\ccm\cache\*-*-*-*-*.1.System>c:\temp\caches.txt")

else

objShell.Run ("cmd /c dir /b c:\windows\syswow64\ccm\cache\*-*-*-*-*.1.System>c:\temp\caches.txt")

End If

If objFSO.FileExists ("C:\temp\caches.txt") Then
    Set objFile = objFSO.OpenTextFile("C:\temp\caches.txt", 1)
    Do Until objFile.AtEndOfStream
        strLine = objFile.ReadLine
‘Wscript.Echo strLine
dirPath = "c:\windows\system32\ccm\cache\" & strLine
‘Wscript.Echo dirPath
objFSO.DeleteFolder dirPath, True
Wscript.Sleep 10
    Loop
    objFile.Close
End If
Wscript.Quit(0)

You can also power shell script to do this activity ,for more info please refer http://www.myitforum.com/absolutenm/templates/Articles.aspx?articleid=18962&zoneid=89

Tags: , , , , , , , , ,
Posted in SCCM 2007, Scripting, Software Updates | No Comments »