Difference between revisions of "Adding Registry Settings"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(Cleanup)
Line 1: Line 1:
You can use regedit to silently import registry settings. This can be useful to setup defaults for applications, or apply  
+
= RegEdit =
[http://www.winguides.com/registry/ registry tweaks for various Windows settings].
+
 
 +
Windows has a registry editing program called RegEdit which can be used interactively or it can be scripted. This can be useful to setup defaults for applications, or apply [http://www.winguides.com/registry/ registry tweaks for various Windows settings].
 +
 
 +
To run RegEdit interactively, run the program <code>regedit.exe</code>.
 +
 
 +
To script the amendment of the registry using RegEdit, use it in the form <code>regedit.exe /s <filename>.reg</code>.
 +
 
 +
You can use RegEdit from WPKG to silently import registry settings, for example:
 
<source lang="xml">
 
<source lang="xml">
 
  <package
 
  <package
 
     id="sample_registry"
 
     id="sample_registry"
     name="Shows a registry entry"
+
     name="Adds the contents of a .reg file to the registry"
 
     revision="1"
 
     revision="1"
 
     priority="0"
 
     priority="0"
Line 17: Line 24:
 
<code>test_registry.reg</code>:
 
<code>test_registry.reg</code>:
 
<source lang="reg">
 
<source lang="reg">
 +
Windows Registry Editor Version 5.00
 +
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Test]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Test]
 
"Test Setting"=dword:00000001
 
"Test Setting"=dword:00000001
 
[-HKEY_LOCAL_MACHINE\SOFTWARE\TEST2]
 
[-HKEY_LOCAL_MACHINE\SOFTWARE\TEST2]
 
</source>
 
</source>
(In Win2k/XP adding "-" in front of a key name causes that key to be deleted from the registry.)
+
(In Windows 2000/XP, adding "-" in front of a key name causes that key to be deleted from the registry.)
  
Normally, you would export this from regedit.exe.
+
You can create ready-made .reg files by exporting registry keys from within RegEdit.
  
 +
= Reg =
  
Alternatively, in most modern versions of Windows, there is also a command line registry editor, reg.exe. This can add/delete/modify registry keys without the need for a .reg file.
+
Alternatively, included with Windows 2000 Resource Kit, or with Windows XP itself, there is a command line registry editor, reg.exe, that can be used more directly from the command-line. For example:
The matching install command to the above example would be:
+
<code><pre>REG ADD HKLM\SOFTWARE\Test /v "Test Setting" /d "1" /t REG_DWORD</pre></code>
<code><pre>
+
REG ADD HKLM\SOFTWARE\Test /v "Test Setting" /d "1" /t REG_DWORD
+
</pre></code>
+
 
----
 
----
  
 
[[Category: Silent Installers]]
 
[[Category: Silent Installers]]
 
[[Category: Changing Windows settings]]
 
[[Category: Changing Windows settings]]

Revision as of 09:51, 21 April 2010

RegEdit

Windows has a registry editing program called RegEdit which can be used interactively or it can be scripted. This can be useful to setup defaults for applications, or apply registry tweaks for various Windows settings.

To run RegEdit interactively, run the program regedit.exe.

To script the amendment of the registry using RegEdit, use it in the form regedit.exe /s <filename>.reg.

You can use RegEdit from WPKG to silently import registry settings, for example:

 <package
     id="sample_registry"
     name="Adds the contents of a .reg file to the registry"
     revision="1"
     priority="0"
     execute="once">
   <check type="registry" condition="equals" path="HKEY_LOCAL_MACHINE\SOFTWARE\Test" value="1" />
   <install cmd='regedit /s "%SOFTWARE%\test_registry.reg"' />
 </package>

And the sample file:

test_registry.reg:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Test]
"Test Setting"=dword:00000001
[-HKEY_LOCAL_MACHINE\SOFTWARE\TEST2]

(In Windows 2000/XP, adding "-" in front of a key name causes that key to be deleted from the registry.)

You can create ready-made .reg files by exporting registry keys from within RegEdit.

Reg

Alternatively, included with Windows 2000 Resource Kit, or with Windows XP itself, there is a command line registry editor, reg.exe, that can be used more directly from the command-line. For example:

REG ADD HKLM\SOFTWARE\Test /v "Test Setting" /d "1" /t REG_DWORD