prologic08
asked on
Deleting Temporary Files using SCCM or GPO or something else.
Does anyone have a way that they periodically delete temporary files on a machine via SCCM or GPO or another method. When I do a Disk Cleanup on some machines on occasion, the temporary files sometimes hit over 50GB. What is the easiest way to set a task to delete these on 1000+ machines periodically? BTW..this is not just for Temporary internet files. I would want it to delete all temp files including hidden files and read only files. This is on Windows 7.
I use CCleaner from Piriform.com and have a logoff script that automatically runs it.
ASKER
I cannot use CCleaner for this although I do use it personally. Thank you Gabriel.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What I am thinking is using Gabriel's script and making a task sequence for each folder to delete and running it monthly.
ASKER
Do you think it is ok to delete the ccmcache as well?
From what I know about ccmcache is that the ccm server should automatically clear the cache. If you manually clear the cache and the ccm server purposely left something there, it could cause issues.
ASKER
Gotcha. My assumption is that any files that are put there and are still being used are caused by the way I create the script. For instance, I was creating a script that dropped an icon on the desktop. I accidentally added the icon to the ccmcache instead of copying it to another location and when I deleted the folder in the ccmcache, the icon stopped showing.
ASKER
So I ultimately decided to go with a Task Sequence in SCCM. But..of course..I am having problems with it deleting in Windows 8.1. I have no issue in Windows 7.
I created 6 tasks to run a command line.
Task 1: Delete Prefetch Directories
Task 2: Delete Prefetch FIles
Task 3: Delete Local Temp Files
Task 4: Delete Windows Temp Files
Task 5: Delete Temporary Internet Files - W7
Task 6: Delete Temporary Internet Files - W8.1
This deletes everything correctly in Win 7 but deletes nothing in Win 8. Would someone be able to modify the command lines to allow it to delete in both Win7 and Win 8? I assume I could have made this look cleaner and shorter.. There is no need to have multiple tasks, I just did it cause I didn't know any other way..
Any help is greatly appreciated.
I created 6 tasks to run a command line.
Task 1: Delete Prefetch Directories
CMD.exe /S /C rmdir "C:\Windows\PreFetch\ReadyBoot" /s/q
Task 2: Delete Prefetch FIles
CMD.exe /S /C del "C:\Windows\PreFetch\*" /s/q
Task 3: Delete Local Temp Files
CMD.exe /S /C for /f "delims=|" %f in ('dir /B /A:D-H-R c:\users') do del /s /q "C:\Users\%f\AppData\Local\Temp\*"
Task 4: Delete Windows Temp Files
CMD.exe /S /C del "C:\Windows\temp\*" /s/q
Task 5: Delete Temporary Internet Files - W7
CMD.exe /S /C for /f "delims=|" %f in ('dir /B /A:D-H-R c:\users') do del /s /q "C:\Users\%f\AppData\Local\Microsoft\Windows\Temporary Internet Files\*"
Task 6: Delete Temporary Internet Files - W8.1
CMD.exe /S /C for /f "delims=|" %f in ('dir /B /A:D-H-R c:\users') do del /s /q "C:\Users\%f\AppData\Local\Microsoft\Windows\INetCache\*"
This deletes everything correctly in Win 7 but deletes nothing in Win 8. Would someone be able to modify the command lines to allow it to delete in both Win7 and Win 8? I assume I could have made this look cleaner and shorter.. There is no need to have multiple tasks, I just did it cause I didn't know any other way..
Any help is greatly appreciated.
Hi,
I can understand you want to spring clean machines but it seems you've got over-zealous. In general, anything that is cache-based is best left alone. You've already found that with ccmcache. It also applies to prefretch. Do NOT clean them out. It's a complete urban myth from XP days. I expect W7, 8 and later are either the same or more efficient.
C:\Windows\PreFetch\ReadyB oot" - leave alone
C:\Windows\PreFetch - leave alone
C:\Users\%f\AppData\Local\ Temp\* - ok
C:\Windows\temp\*" - ok
C:\Users\%f\AppData\Local\ Microsoft\ Windows\Te mporary Internet Files\* - better to fix that with a GPO
For a good article on pre-fetch, please see here:
http://www.edbott.com/weblog/2005/06/one-more-time-do-not-clean-out-your-prefetch-folder/
It's 2005 but as valid today as it ever was.
I don't have W8 to try testing the commands, so can't help on that. Do the commands work manually?
Mike
I can understand you want to spring clean machines but it seems you've got over-zealous. In general, anything that is cache-based is best left alone. You've already found that with ccmcache. It also applies to prefretch. Do NOT clean them out. It's a complete urban myth from XP days. I expect W7, 8 and later are either the same or more efficient.
C:\Windows\PreFetch\ReadyB
C:\Windows\PreFetch - leave alone
C:\Users\%f\AppData\Local\
C:\Windows\temp\*" - ok
C:\Users\%f\AppData\Local\
For a good article on pre-fetch, please see here:
http://www.edbott.com/weblog/2005/06/one-more-time-do-not-clean-out-your-prefetch-folder/
It's 2005 but as valid today as it ever was.
I don't have W8 to try testing the commands, so can't help on that. Do the commands work manually?
Mike