Thursday, January 27, 2011

How to Export Registry Keys Through Batch File

Long time ago I wrote a post on having a deal with Windows registry in batch files. It's time to return to this topic and share a small, but still very useful batch file that will help you to export registry keys to a REG file. This code is really simple, still you can include it into complex script that you create with help of our powerful batch files editor.
Here is the code of this batch file:
@echo off regedit /ea %Temp%\ChkReg.txt "HKEY_CURRENT_USER\Software\MyPrg-1" if exist %Temp%\ChkReg.txt type %Temp%\ChkReg.txt>reg.reg regedit /ea %Temp%\ChkReg.txt "HKEY_LOCAL_MACHINE\Software\MyPrg-1" if exist %Temp%\ChkReg.txt findstr /v /b /i "REGEDIT4" %Temp%\ChkReg.txt>>reg.reg if exist %Temp%\ChkReg.txt del %Temp%\ChkReg.txt
As far as you can see, first of all we export the necessary keys to ChkReg.txt, than copying data itself to REG file, and then remove the temporary TXT. Hope this script will be useful for you.

No comments:

Post a Comment

Translate