Restore Windows XP PC from corrupted registery

This article describes how to recover a Windows XP system that does not start because of corruption in the registry. This procedure does not guarantee full recovery of the system to a previous state; however, you should be able to recover data when you use this procedure. Here is the source code that you'll need […]

This article describes how to recover a Windows XP system that does not start because of corruption in the registry. This procedure does not guarantee full recovery of the system to a previous state; however, you should be able to recover data when you use this procedure. Here is the source code that you'll need to paste into any text editor and save as RegistryRecovery.bat:

Note: It’s better to pluggin the HDD with the corrupted registry into another working PC then load the batch. It will first ask you for a drive letter, then the windows installation folder. Press Ctrl+C at any time to exit the batch. When done, just plug the HDD back to it's original PC and boot.

@echo off
:init
cls
title Registry Recovery XP
echo ====================
echo Registry Recovery XP
echo ====================
echo      (by diTii.com)
echo.
:drv
set drv=
set /P drv=Drive letter (ie.: C, D, E...)? 
if not exist %drv%:\nul (echo Invalid drive!&pause&goto init)
:win
set win=
set /P win=Windows folder (ie.: windows, winnt...)? 
%drv%:
cd \
if not exist "%win%" (echo Folder not found!&goto win)
if not exist "%win%\system32\config" (echo Not a Windows folder!&goto win)

:start
:: Backup current registry files
echo.
echo - Backing up registry files to "%drv%:\tmp"...
md tmp 2>nul
copy %drv%:\%win%\system32\config\system %drv%:\tmp\system.bak >nul
copy %drv%:\%win%\system32\config\software %drv%:\tmp\software.bak >nul
copy %drv%:\%win%\system32\config\sam %drv%:\tmp\sam.bak >nul
copy %drv%:\%win%\system32\config\security %drv%:\tmp\security.bak >nul
copy %drv%:\%win%\system32\config\default %drv%:\tmp\default.bak >nul

:: Delete registry files
echo.
echo - Deleting registry files from "%drv%:\%win%\system32\config"...
del %drv%:\%win%\system32\config\system 2>nul
del %drv%:\%win%\system32\config\software 2>nul
del %drv%:\%win%\system32\config\sam 2>nul
del %drv%:\%win%\system32\config\security 2>nul
del %drv%:\%win%\system32\config\default 2>nul

:: Recover registry files from backup
echo.
echo - Recovering registry files from "%drv%:\%win%\repair"...
copy %drv%:\%win%\repair\system %drv%:\%win%\system32\config\system >nul
copy %drv%:\%win%\repair\software %drv%:\%win%\system32\config\software >nul
copy %drv%:\%win%\repair\sam %drv%:\%win%\system32\config\sam >nul
copy %drv%:\%win%\repair\security %drv%:\%win%\system32\config\security >nul
copy %drv%:\%win%\repair\default %drv%:\%win%\system32\config\default >nul

echo.
echo Done!
pause