JSI Tip 8346. How do I blow away service pack and hotfix uninstall registry entries AND folders?

Jerold Schulman

August 9, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

My systems always seem to have excess service pack and hotfix uninstall folders, and registry entries, mostly from my participation in the betas.

Prior to installing a new service pack release, I use DelHotFix.bat to delete all previous service pack and hotfix uninstall folders, and the Control Panel / Add or Remove Programs registry entries.

NOTE: I am NOT recommending that you do this, but you could run the DelHotFix.bat in display mode.

The syntax for using DelHotFix.bat is:

DelHotFix [/D]

Where /D is an optional switch that causes the folder and registry key deletion.

DelHotFix.bat contains:

@echo offsetlocal@echo DelHotFix [/D]set sw=%1set key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstallset blank= set fnd=findstr /L /Ifor /f "Tokens=*" %%a in ('reg query %key% ^|%fnd% /C:"UninstallKB"') do ( set UK=%%a call :parse)for /f "Tokens=*" %%a in ('reg query %key% ^|%fnd% /C:"UninstallQ0"') do ( set UK=%%a call :parse)for /f "Tokens=*" %%a in ('reg query %key% ^|%fnd% /C:"UninstallQ8"') do ( set UK=%%a call :parse)set key="HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstallWindows 2000 Service Pack"call :SPset key="HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstallWindows XP Service Pack"call :SPset key="HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstallWindows Server 2003 Service Pack"call :SPif /i "%sw%" NEQ "/D" dir /b /a /ad "%SystemRoot%$NT*"if /i "%sw%" NEQ "/D" goto finishfor /f "Tokens=*" %%d in ('dir /b /a /ad "%SystemRoot%$NT*"') do ( @echo Deleting "%SystemRoot%%%d" rd /s /q "%SystemRoot%%%d"):finishendlocalgoto :EOF:parseset UK=HKLM%UK:~18%for /f "Tokens=2*" %%b in ('reg Query "%UK%" /v DisplayName') do ( set name=%%c)if /i "%sw%" NEQ "/D" @echo %UK% %blank% %blank% %name%if /i "%sw%" NEQ "/D" goto :EOF@echo REG DELETE %UK% /FREG DELETE %UK% /F@echogoto :EOF:SPset OK=Ncall :SPX>nul 2>&1if "%OK%" EQU "N" goto :EOFif /i "%sw%" NEQ "/D" @echo %key%&goto :EOFset UK=%key%@echo REG DELETE %UK% /FREG DELETE %UK% /F@echogoto :EOF:SPXfor /f "Tokens=*" %%a in ('reg query %key%') do ( set OK=Y)



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like