Today I found myself cleaning up my C: drive on one of my servers. One of the offending folders was C:\Windows\Installer. Be careful what you delete from this folder as you will run into another headache if you ever find yourself trying to uninstall a program (and possibly other annoyances) and the associated msp file is not there.
Microsoft has created a tool called msizap.exe that SHOULD clean this folder up for you by deleting all the orphaned patches. However, upon running:
I got the following error:
MsiZapInfo: Performing operations for user S-1-5-21-2914546075-379062757-4049983416-500
Removing orphaned cached files.
Error enumerating Products key for S-1-5-21-2914546075-379062757-4049983416-500 user. Error: 6.
FAILED to clear all data.
After googling this error, I found no solutions on how to resolve it. So, I found myself cleaning this folder the hard way, but not as hard as it could have been. If you go here:
Someone from the msdn blog has created a script (wimsps.vbs) to show you which patches are registered. These are the files you DON'T want to delete. So, I modified the script to move these files to another directory, so they are out of my way while I sift through the other files. There are a couple of things to do before running the script:
- The first is to create a backup directory for your registered patches. (Otherwise, the script will error that the backup directory isn't there. (I realize I could modify the script to make the directory, but...I won't be using this script often and it's simply faster to create the directory.)
- The second thing to do is change the bakfolder variable to the proper path of your backup directory then run the script.
Now you can go through the rest of the C:\Windows\Installer directory and not have to compare it to the script output list of registered patches. Once you are done, simply copy the registered files back to the C:\Windows\Installer directory, delete your backup directory, and you're done. The modified script is attached.
Also, in order to speed up the process of identifying what each file is (so you don't have to right click and go through the properties of each file), right click on the header bar (or whatever it's called...the bar with Name, Size, Type, etc.) and choose Author, Title and Comment. Assuming you are using the "Details" view (View > Details), you will now see three new columns of useful information (that you can also sort by) to help you identify each file. My recommendation would be, if you don't know what the file is, don't delete it. Anything that is not authored by Microsoft, I tend to leave it. Everything that is authored by Microsoft, I simply move to another drive and delete at a later date.
You have to run the cmd windows as Administrator or you'll probably get Permission Denied when the script tries to move the files. Also, run the script in the following way: