Backup Registry Hives
Hi Everyone,
I have created batch script for backing up registry hives this batch script will create two folders at root of C: partition and stores copies of registry hives. The folder named Registry_Backups will contain newly created registry hives and previously created copies of registry hives, these previous backups will have OLD extension. The C:\Registry_Backups\RegOld folder contains previously created registry hive files with OLD extension. This batch script can be schedule to make backup copies of the registry hive files at any given time, i have setup a schedule to make sure my registry hives are backup at logon time.
Execute the batch script with administrative privileges.
Please copy/paste batch scripts codes to Notepad and save it as RegBackup.bat.
I have created batch script for backing up registry hives this batch script will create two folders at root of C: partition and stores copies of registry hives. The folder named Registry_Backups will contain newly created registry hives and previously created copies of registry hives, these previous backups will have OLD extension. The C:\Registry_Backups\RegOld folder contains previously created registry hive files with OLD extension. This batch script can be schedule to make backup copies of the registry hive files at any given time, i have setup a schedule to make sure my registry hives are backup at logon time.
Execute the batch script with administrative privileges.
Code:
:: Created By FreeBooter
:: http://www.geekpolice.net
@Echo Off & Cls
Echo.
Call :IsAdmin
If Not Exist C:\Registry_Backups (md C:\Registry_Backups) Else (Goto :Skip)
If Not Exist C:\Registry_Backups\RegOld (Md C:\Registry_Backups\RegOld) Else (Goto :Skip)
:Skip
if exist C:\Registry_Backups\DEFAULT.OLD move /Y C:\Registry_Backups\DEFAULT.OLD C:\Registry_Backups\RegOld
if exist C:\Registry_Backups\SAM.OLD move /Y C:\Registry_Backups\SAM.OLD C:\Registry_Backups\RegOld
if exist C:\Registry_Backups\SECURITY.OLD move /Y C:\Registry_Backups\SECURITY.OLD C:\Registry_Backups\RegOld
if exist C:\Registry_Backups\SOFTWARE.OLD move /Y C:\Registry_Backups\SOFTWARE.OLD C:\Registry_Backups\RegOld
if exist C:\Registry_Backups\SYSTEM.OLD move /Y C:\Registry_Backups\SYSTEM.OLD C:\Registry_Backups\RegOld
if exist C:\Registry_Backups\NTUSER.OLD move /Y C:\Registry_Backups\NTUSER.OLD C:\Registry_Backups\RegOld
If Exist C:\Registry_Backups\DEFAULT Ren C:\Registry_Backups\DEFAULT DEFAULT.OLD 2>&1 > Nul
If Exist C:\Registry_Backups\SAM Ren C:\Registry_Backups\SAM SAM.OLD 2>&1 > Nul
If Exist C:\Registry_Backups\SECURITY Ren C:\Registry_Backups\SECURITY SECURITY.OLD 2>&1 > Nul
If Exist C:\Registry_Backups\SOFTWARE Ren C:\Registry_Backups\SOFTWARE SOFTWARE.OLD 2>&1 > Nul
If Exist C:\Registry_Backups\SYSTEM Ren C:\Registry_Backups\SYSTEM SYSTEM.OLD 2>&1 > Nul
If Exist C:\Registry_Backups\NTUSER.DAT Ren C:\Registry_Backups\NTUSER.DAT NTUSER.OLD 2>&1 > Nul
If %Errorlevel% GTR 0 (
@Echo Set oWshShell = WScript.CreateObject^("WScript.Shell"^) > %Tmp%\Popup.vbs
@Echo oWshShell.Popup "Error Backing Registry Hives" , 15, "Registry Hive Backup Error", 0 >> %Tmp%\Popup.vbs
Wscript %Tmp%\Popup.vbs
)
If Exist "%Tmp%\Popup.vbs" Del %Tmp%\Popup.vbs >nul
REG SAVE HKU\.DEFAULT C:\Registry_Backups\DEFAULT
REG SAVE HKLM\SAM C:\Registry_Backups\SAM
REG SAVE HKLM\SECURITY C:\Registry_Backups\SECURITY
REG SAVE HKLM\SOFTWARE C:\Registry_Backups\SOFTWARE
REG SAVE HKLM\SYSTEM C:\Registry_Backups\SYSTEM
REG SAVE HKCU C:\Registry_Backups\NTUSER.DAT
:IsAdmin
Reg query "HKU\S-1-5-19\Environment"
If Not %ERRORLEVEL% EQU 0 (
Cls & Mode CON LINES=5 COLS=48 & Color 0C & Title - WARNING -
Echo.
Echo.
Echo YOU MUST HAVE ADMINISTRATOR RIGHTS TO CONTINUE
Pause >Nul & Exit
)
Cls
Goto :EOF
Please copy/paste batch scripts codes to Notepad and save it as RegBackup.bat.