Manipulate the registry from a batch fileTag(s): Misc Prog HowTo


CAUTION! Working with the registry can be dangerous!

REGEDIT is usually known as a GUI tool to search or edit the Windows registry but we can use it in batch file too.

The syntax to update the registry is

 REGEDIT.EXE  /S  importfile.REG
/S is to hide confirmation box when importing files.

You can use notepad or wordpad to write registry files, you save them with a .reg extension.

The first line in the registry file for XP or 2000 has to be :

Windows Registry Editor Version 5.00

For Win98, ME, or NT 4.0 it's :

REGEDIT4
then the header is followed by a blank line.

To create a key

[HKEY_CURRENT_USER\Software\RealHowto]
To create a value
[HKEY_CURRENT_USER\Software\RealHowto]
"MyValue"="howto"
To remove a key
[-HKEY_CURRENT_USER\Software\RealHowto]
To remove a value
[HKEY_CURRENT_USER\Software\RealHowto]
"ValueToBeRemoved"=-
By default, a value is a string. To specify a dword simply use the prefix dword :
[HKEY_CURRENT_USER\Software\RealHowto]
"MyValue"=dword:000001

If a semicolon is in front of any line then it will be ignored, it's the way to comment a REG file.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\RealHowto]
; add a value
"MyValue2"=dword:00000001
; delete a value
"MyValue1"=-

blog comments powered by Disqus