Close Menu
    Facebook X (Twitter) Instagram
    Sunday, October 12
    X (Twitter) LinkedIn Reddit RSS
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»SCCM 2007»VB Script to delete Software update files from SCCM client Cache folder

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

    Eswar KonetiBy Eswar KonetiMay 26, 4:01 pm2 Mins Read SCCM 2007 2,653 Views
    Share
    Facebook Twitter LinkedIn Reddit

     

    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

    Cache packages Cache size configmgr configuration Manager SCCM SCCM 2007 script to remove cache folders script to remove sccm client cache folder software update files removal from cache VB Script
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    SCCM SQL Report – Compare Installed Apps on TWO Different Computers

    July 13, 10:35 am

    Optimize Your Intune Workflow with a Powerful Browser Extension

    March 22, 10:39 am

    Migrate Microsoft 365 Updates from SCCM/MECM to Intune for Co-Managed Devices

    February 11, 9:50 pm

    3 Comments

    1. robert on November 24, 2016 6:33 PM

      works fine for 64bit just amend the sccm cache location in the script

      Reply
    2. Adam on July 11, 2014 8:03 PM

      The way your script sites today, it will only work on 32-bit systems. You need a few more lines for it to work on 64-bit system with the syswow folder.

      Reply
      • Eswar Koneti on July 21, 2014 8:57 AM

        Hi Adam,
        that was for 2007 and yes,for 64bit,i missed to add it ,and for cm12 ,location of ccmcache is C:\windows\ccmcache irrespective of Architecture (32 or 64) ,I will try to update the script that works for CM12 environment.
        Thanks for notifying on this.

        Reply

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2025 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.