Adding Registry Settings

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

The Windows Registry is a hierarchical database that stores configuration settings and options on Microsoft Windows operating systems. It contains settings for low-level operating system components as well as the applications running on the platform: the kernel, device drivers, services, SAM, user interface and third party applications all make use of the Registry. The registry also provides a means to access counters for profiling system performance.

There are a number of utilities that allow you to modify the registry. Depending on your reqirements, may be more suitable for you needs. Some come with Windows natively, some can set security permissions as well as modifying entries.

Utilities that can only edit entries

Reg

Command-line registry editor, can be used directly from within WPKG. Included with Windows 2000 Resource Kit, or bundled with Windows from Windows XP onwards. For example, adding a registry value:

reg add HKLM\SOFTWARE\Test /v "Test Setting" /d "1" /t REG_DWORD

For example, deleting a registry value:

reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Picasa Media Detector" /f

RegEdit

NB: When used via the command line Regedit cannot change registry access permissions. When used interactively a user can alter permissions.

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.

Regedit.exe comes with Windows (located at: %SystemRoot%\regedit.exe) so does not need to be installed on a PC by hand or stored in a shared folder.

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.

DTReg

DTReg by David G. Thomas. Freeware. Not available from the author's site at http://www.tamedos.com/downloads/downloads.htm but is available from http://thegoldenear.org/dtreg.zip. The latest known version is 1.0t, circa 2001.

Utilities that can only edit permissions

SubInACL

SubInACL is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.

SubInACL can be downloaded from Microsoft's download site:Download SubInACL


SetACL

SetACL is a free open source software utility that manages permissions, auditing and ownership information in files, folders and the regsitry.

More information can be found at the SetACL website.

Utilities that can edit permissions and entries

Regini

You can modify registry entries and permissions with Regini.exe .

The Regini.exe utility is included in the Windows NT Server 4.0 Resource Kit, in the Microsoft Windows 2000 Resource Kit, and in the Microsoft Windows Server 2003 Resource Kit.

Please see the MS KB article for details: Microsoft KB article 264584

Adding entries to HKCU for all users

If WPKG is run at startup and you use REG or similar to add/edit/delete a registry key to HKEY_CURRENT_USER, it will only affect the WPKG's admin account's registry hive.

Active Setup

Active Setup is useful if you need to add an entry to HKCU for all users of a machine. It works by adding a key to HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\%package name% with a version number. When a user logs in Windows checks this location and compares it to HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\%package name%. If it is missing or a lower version then it runs whatever has been set in HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\%package name%\StubPath.

For example to enable Outlook RPC encryption:

<install cmd='reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\wpkgEnableOutlookEncryption" /v "Version" /d "1" /t REG_SZ /f' />
<install cmd='reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\wpkgEnableOutlookEncryption" /v "StubPath" /d "reg add HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\11.0\Outlook\RPC /v "EnableRPCEncryption" /d "1" /t REG_DWORD /f" /f' />  

Will run "reg add HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\11.0\Outlook\RPC /v "EnableRPCEncryption" /d "1" /t REG_DWORD /f" once for each user as they login.