The field servers in our company are several years old, and new applications are taking up a lot of space on the C drive. To free up some space, I wrote a script, DeleteHotfixBackups.bat, that deletes all the backup folders for Microsoft hotfixes and the associated log files in C:\WINDOWS.
Listing 1 shows DeleteHotfixBackups.bat. Microsoft's backup hotfix folders are hidden folders that start with the $ character. So, in a For loop, the script uses the Dir command to obtain the names of all the hidden folders that begin with the $ character. The script pipes the names to the Do portion of the loop, where the RD command deletes those folders.
To use DeleteHotfixBackups.bat, you simply need to place the script on your server and run it. I wrote this script for Windows Server 2003 and Windows 2000. Note that deleting all the backup hotfix folders can be risky if a hotfix breaks an application and you need to undo that particular hotfix. This script will also remove any backup service-pack folders because they also begin with the $ character.
—Tom Barnett, senior IT analyst, Fortune 250 energy company