Skip navigation

How can I automate updates to the registry?

A. There are 2 main methods you can use to create scripts that can be run to automate the updates. The first is to create a .reg file which can then be run using

regedit /s <reg file>

The format of the file is

REGEDIT4
\[<key name>\]
"<value name>"="<value>"
a string value
"<value name>"=hex:<value>
a binary value
"<value name>"=dword:<value>
a dword value

for example

REGEDIT4

\[HKEY_USERS\.DEFAULT\Control Panel\Desktop\]
"Wallpaper"="E:\\WINNT\\savtech.bmp"
"TileWallpaper"="0"

\[HKEY_USERS\.DEFAULT\Control Panel\Colors\]
"Background"="0 0 0"

Would set the default background and color before anyone logs on.

The second method is to user a Windows 95 style .inf file. These are run using the command

rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 <inf file>

The format of the file is as follows

\[Version\]
Signature = "$Windows NT$"
Provider=%Provider%

\[Strings\]
Provider="SavillTech Ltd"

\[DefaultInstall\]
AddReg = AddReg
DelReg = DelReg
UpdateInis = UpdateInis

\[AddReg\]
\[DelReg\]
\[UpdateInis\]

Below are the keys to be used

HKCR HKEY_CLASSES_ROOT
HKCU HKEY_CURRENT_USER
HKLM HKEY_LOCAL_MACHINE
HKU HKEY_USERS

The file below is an .inf file which performs the same as the .reg file described earlier

\[Version\]
Signature = "$Windows NT$"

\[DefaultInstall\]
AddReg = AddReg

\[AddReg\]
HKU,".DEFAULT\Control Panel\Colors","Background",0000000000,"0 0 0"
HKU,".DEFAULT\Control Panel\Desktop","Wallpaper",0000000000,"E:\WINNT\savtech.bmp"
HKU,".DEFAULT\Control Panel\Desktop","TileWallpaper",0000000000,"1"

INF files can be generated automatically using the SYSDIFF utility if you have a difference file (sysdiff /inf <name of difference file> <dir to create to>)

A registry entry can also be deleted using .REG files. That is, if one has a .reg file with, e.g.,

\[HKEY_CURRENT_USER\Test\]

to enter a key, then one can use

\[-HKEY_CURRENT_USER\Test\]

to remove it.


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish