Monday, 26 July 2021

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

Create Notepad File and save it as Filename.vbs
http://eskonr.com/2012/05/vb-script-to-delete-software-update-files-from-sccm-client-cache-folder/

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)

Share:

0 $type={blogger}:

Post a Comment