05 February 2009

vb script To Clear SCCM / SMS CCM / Cache Folder

To Clear SCCM / SMS CCM / Cache Folder
 
 
' Script to Clear SMS cache files
on error resume next
dim oUIResManager
dim oCache
dim oCacheElement
dim oCacheElements
set oUIResManager = createobject("UIResource.UIResourceMgr")
if oUIResManager is nothing then
'      wscript.echo "Couldn't create Resource Manager - quitting"
     wscript.quit
end if
set oCache=oUIResManager.GetCacheInfo()
if oCache is nothing then
     set oUIResManager=nothing
'      wscript.echo "Couldn't get cache info - quitting"
     wscript.quit
end if
set oCacheElements=oCache.GetCacheElements
'wscript.echo "There are " & oCacheElements.Count & " cache elements"
'wscript.echo
' ***** Begin CLEAR CACHE *****
for each oCacheElement in oCacheElements
oCache.DeleteCacheElement(oCacheElement.CacheElementID)
next
' ***** End CLEAR CACHE *****
' ***** Clean up *****
set oCacheElements=nothing
set oUIResManager=nothing
set oCache=nothing

-------------------
Thanks,
http://sccm07.blogspot.com/

No comments: