Longtime reader Jim ` offered to share his oh-so-sneaky method for killing temp files. I’m happy to share them today.
Jim’s commentary is in plain Roman type. The file contents are in boldface. This trick works because the first file causes the second to run early in the boot process, when some of these files are still out of use and deletable. That’s why Jim’s trick works for things that CCleaner can’t.
I recommend running this around the time of Patch Tuesday. That way, when your computer reboots, it’ll do some cleanup as it comes back. If you’re like me, that’s the only time the computer gets rebooted on any kind of a regular basis.
Here’s Jim.
1. Use this file to create a little registry entry to call the bat file on start-up. Some files can only be deleted before Windows fully starts, which is why I use this method. It will only run once. I stow it in a directory off the Start Menu called “Maintenance” where I keep a bunch of other maintenance related utilities.
Tempwin.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
"TempwinONCE"="C:\\tempwin.bat"
2. My user name is “A Valued Customer” but I’m sure you figured that out. You’d have to change it to whatever you’re using as a User Name. Save this file as C:\Tempwin.bat
attrib -a -r -s -h “c:\documents and settings\a valued customer\local settings\history\*.*” /d /s
rd /q /s “c:\documents and settings\a valued customer\local settings\history\”
attrib -a -r -s -h “c:\documents and settings\administrator\local settings\history\*.*” /d /s
rd /q /s “c:\documents and settings\administrator\local settings\history\”
attrib -a -r -s -h “c:\temp\Temporary Internet Files\*.*” /d /s
rd /q /s “c:\temp\Temporary Internet Files\”
attrib -a -r -s -h “c:\Documents and Settings\All Users\Application Data\Avg9\Log\*.*” /d /s
rd /q /s “c:\Documents and Settings\All Users\Application Data\Avg9\Log\”
attrib -a -r -s -h “c:\Documents and Settings\All Users\Application Data\Avg9\emc\Log\*.*” /d /s
rd /q /s “c:\Documents and Settings\All Users\Application Data\Avg9\emc\Log\”
attrib -a -r -s -h “C:\Documents and Settings\A Valued Customer\Application Data\Microsoft\Office\Recent\*.*” /d /s
rd /q /s “C:\Documents and Settings\A Valued Customer\Application Data\Microsoft\Office\Recent\”
attrib -a -r -s -h “C:\Documents and Settings\administrator\Application Data\Microsoft\Office\Recent\*.*” /d /s
rd /q /s “C:\Documents and Settings\administrator\Application Data\Microsoft\Office\Recent\”
attrib -a -r -s -h “C:\Documents and Settings\A Valued Customer\Recent\*.*” /d /s”
rd /q /s “C:\Documents and Settings\A Valued Customer\Recent\”
attrib -a -r -s -h “C:\Documents and Settings\A Valued Customer\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache\*.*” /d /s
rd /q /s “c:\Documents and Settings\A Valued Customer\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache\”
attrib -a -r -s -h “C:\Documents and Settings\A Valued Customer\Local Settings\Application Data\Google\GoogleEarth\*.*”rd /q /s “c:\Documents and Settings\A Valued Customer\Local Settings\Application Data\Google\GoogleEarth\*.*”
del “C:\Documents and Settings\A Valued Customer\Application Data\Lavasoft\Ad-Aware\logs\AWEVLOG.txt”
I manually sort through and delete the rest of the crap that ends up in the Temp directory, including those darned GoogleUpdate directories. What’s with those guys? They should know better than that…
David Farquhar is a computer security professional, entrepreneur, and author. He started his career as a part-time computer technician in 1994, worked his way up to system administrator by 1997, and has specialized in vulnerability management since 2013. He invests in real estate on the side and his hobbies include O gauge trains, baseball cards, and retro computers and video games. A University of Missouri graduate, he holds CISSP and Security+ certifications. He lives in St. Louis with his family.
Reaching for some content today, eh Dave? 😀
I’ve since discovered it’s not Google but AVG which leaves some empty crypto-numeric directory in my TEMP folder every bloody day.
At least I didn’t have to reach too far. I try to keep something like this nearby for those days when I’m short on ideas. I have something in the works that I think will be really good (or at least helpful, and it’ll save people 30 bucks) but it’ll be at least another day before it’s ready. Maybe not until the weekend.
AVG, huh? How nice of them. A quick glance suggests MSSE may be a bit better behaved in that regard. At least if it’s leaving cruft behind, it’s not in the typical temp directory.