Jump to content

Small script to undo Registry changes done by ".reg"


rayser

Recommended Posts

Just a small script wich u can use before you use a .reg file to later undo the changes:

A cmd-Genius might want to correct some stuff and post it back here (but it worked for me):

just start it, it will ask you wich reg-file to "secure" and where to save the backup of your registry

@echo off
cd "%~dp0"

set /P regfile=Wich Regfile to parse?
set /P bkpdir=Backup Subdirectory?

for /F "eol=; delims= tokens=1" %%i in (%regfile%) do call :Parse1 %%~i

echo step2

for /F "delims= tokens=1" %%j in (temp.txt) do call :Unique %%~j

echo step3

set counter=1
if not exist ".\%bkpdir%" md ".\%bkpdir%"
for /F "delims= tokens=1" %%l in (uniq.txt) do call :BKP %%~l

if exist ".\temp.txt" del ".\temp.txt"
if exist ".\uniq.txt" del ".\uniq.txt"




goto:EOF

:BKP
set str=%*
set bf=.\%bkpdir%\%counter%.hive
reg save "%str%" "%bf%" > NUL
IF ERRORLEVEL 1 (echo reg delete "%str%">> .\%bkpdir%\writeback.cmd) else (echo reg restore "%str%" ".\%counter%.hive">> .\%bkpdir%\writeback.cmd)
SET /A COUNTER+=1
goto:EOF

:Unique
set str=%*
if "%str%"=="" goto:EOF
if exist .\uniq.txt goto Compare
echo %*>> .\uniq.txt
:Compare
for /F "delims= tokens=1" %%k in (uniq.txt) do if "%%k"=="%str%" goto:EOF
echo %*>> .\uniq.txt
goto:EOF

:Parse1
SET str=%*
if not "%str:~0,1%"=="[" goto:EOF
if "%str:~1,1%"=="-" goto BKP2
echo %str:~1,-1%>> .\temp.txt
goto:EOF
:BKP2
echo %str:~2,-1%>> .\temp.txt
goto:EOF

Edited by rayser
Link to comment
Share on other sites


  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...