Vista Registry – How to Create .Reg Files

Vista Registry – How to Create .Reg Files

This page explains how to create a .reg file.  The idea is that you can double-click a .reg file and thus merge its values with those in your Vista registry.  One advantage of a .reg file is that it is easy to apply; you don’t need to drill down through endless keys, as you would with regedit.  Another advantage is because it’s a text file you can open with Notepad and then edit the values easily.  An additional benefit is that .reg files provide their own built-in documentation for changes that you make to the registry.

 ♦

Purpose of .Reg Files

The main purpose of .Reg files is to modify the operating system’s behaviour by changing values in your registry.  Perhaps you have seen such .reg files as part of a program’s installation package?  It is deceptively easy to merge a .reg file with your registry, you simply double-click a text file with .reg extension.  An alternative method is to introduce the values held in the .reg file by using regedit’s import facility.  Where you need to automate a registry change, you could script the command: regedit /s path to .reg file.

Whilst it is easy to import the contents of a .reg file into the registry, do make sure you know what you are doing.  Remember that unlike clicking in a GUI, there are no internal checks on the consequences of changing the registry values.  I leave creating and testing the content of the .reg files to other dedicated pages, on this page I want to concentrate on the general techniques for creating a .reg file.

Getting Started with .reg files

The easiest way to begin is by launching regedit, then select the value you are investigating and exporting that branch of the registry.  Naturally, allow regedit to save the file with a .reg extension. 

Once you have created the experimental file, examine it in Notepad.  Right-click the file and then select: ‘Open with’.   If necessary make changes to the values and then import the .reg file into the registry.  When you have perfected the .reg, you can import its settings to different machines.

How to Create .Reg Files with Registry Export

  1. Launch Regedit.  Click on the Vista Start Button, type ‘Regedit’ in the ‘Start Search’ dialog box.
  2. Navigate to the area of the registry that you are interested in, for example:
    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinlogonVista registry create .reg files
  3. File Menu – Export.  From inside Regedit, click on the File menu, select Export and choose ‘Selected Branch’.  Note the .reg file extension.
  4. Remember the path.  The default path will be ‘Documents’, however you may wish to save the .reg files into a dedicated folder, for example c:\ reg.

Open the .Reg File With Notepad

Beware, if you double click a .reg file the default behaviour is for Vista to try and add the contents to your registry.  The best procedure for reading the .reg file is to right-click and then select ‘Edit’, or ‘Open with’, from the shortcut menu; what that does is open the xyz.reg file in notepad.

Example .reg file from the Winlogon registry folder.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"ReportBootOk"="1"
"Shell"="explorer.exe"
"Userinit"="C:\\Windows\\system32\\userinit.exe,"
"VmApplet"="rundll32 shell32,Control_RunDLL \"sysdm.cpl\""
"AutoRestartShell"=dword:00000001
"LegalNoticeCaption"=""
"LegalNoticeText"=""
"PowerdownAfterShutdown"="0"
"ShutdownWithoutLogon"="0"
"cachedlogonscount"="10"
"forceunlocklogon"=dword:00000000
"passwordexpirywarning"=dword:0000000e
"Background"="0 0 0"
"DebugServerCommand"="no"
"WinStationsDisabled"="0"
"DisableCAD"=dword:00000000
"scremoveoption"="0"
"ShutdownFlags"=dword:00000027
"AutoAdminLogon"="1"
"DefaultUserName"="Guyt"
"DefaultPassword"="P@@sw0rd"
"DefaultDomainName"="cp"
"Welcome"="Guy’s World"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions]

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Orion performance monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds’ Network Performance Monitor

Dissecting the .Reg Files

Registry Editor

Quite reasonably, the, very first line of your .reg file contains the name of the Registry editor. For Vista, XP and Windows Server 2003, the correct name is: ‘Windows Registry Editor Version 5.00’.  Older registries such as Windows 95 and NT 4.0 use ‘REGEDIT4’.  Later registries are backwardly compatible, thus Vista understands ‘REGEDIT4’.  Incidentally, even though Vista’s regedit reports to be version 6.0 in its Help / ‘About’ menu, the .reg files that it creates report to be from Version 5.00, strange but true.

Windows Registry Editor Version 5.00

; Created by Guy Thomas
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Values"="settings"

Blank Lines

You need a blank line between each set of .reg paths.  There is also a blank line between the Registry Editor Version, and the first path.  There is no need for a blank line between individual entries for the same path.  (See first example in the blue table above.)

; Comments

If you create your own .reg file, then it is possible to place judicious comments by preceding that line with a semi-colon.

Windows Registry Editor Version 5.00

; Created by Guy Thomas. Purpose to display the Build Number on the desktop
[HKEY_CURRENT_USER\Control Panel\Desktop]
"PaintDesktopVersion"=dword:00000001

; Created by Guy Thomas.  Purpose to display the Build Number on the desktop.

The Body of a .reg File

The registry is huge.  Consequently, one of the first lines in the .reg file is the path to the values you wish to merge.  Observe the [square brackets] which enclose the path, for example:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

One .reg file can contain multiple paths.  For simplicity, I have truncated the exported .reg file (above) and not shown the second and third paths.  If you try this export experiment you will see zillions of Group Policy settings underneath:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions]

A plain entry in the .reg file means a REG_SZ type of value, for example: "Shell"="explorer.exe".  With hexadecimal entries, note the word dword to the right of the equals sign, for example: "passwordexpirywarning"=dword:0000000e.  Incidentally, 0000000e in hex is 14 in decimal.

REG_DWORDS take only hexadecimal numbers, whereas REG_SZ are more flexible and take text or decimal numbers.

See more examples from Windows 7 .reg files.

Deleting Registry Entries

The secret of deleting registry entries is to master the minus [-] sign.  Earlier, I mentioned the phrase, ‘add keys and values’, strictly speaking, I should have used the word merge instead of add.  The default behaviour is to keep all existing registry entries, and append the values in the .reg file.  However, if the new value creates a conflict, the .reg setting wins. 

If you want to delete an existing entry, then you need to master the minus sign.  Here is an example,
to recap, we set DefaultPassword with:
"DefaultPassword"="P@$sw0rd"

To delete the value called DefaultPassword append equals and then minus, like this:
"DefaultPassword"=-

Note if you erroneously enclosed the minus sign in speech marks ("-"), then you would be setting the default password as equal to minus – probably not what you intended.
"DefaultPassword"=-  (Correct)
"DefaultPassword"="-" (Wrong)

Registry TypesCreating a Vista .reg file

By far the most common registry types are REG_SZ (String Value) and REG_DWORD (dword). However, to see the full list, call for regedit and right-click in the right pane, select New, and now you should see a list of all the possible registry types, see the screen shot to the right.

Key – Means, give me a new folder, or a new container object.
String Value – Text or numbers.
Binary Value (REG_RESOURCE_LIST) – Machine readable 1 and 0 used by drivers.
DWORD (32-bit) Value – Hexadecimal value (not decimals).
QWORD (64-bit) Value – Hexadecimal, capable of even bigger numbers.
Multi-String (REG_EXPAND_SZ).  String values separated by commas or spaces.
Expandable String Value – Expandable in the sense that they can contain variables which are resolved when a program calls for this data.

Recommended: Solarwinds’ Permissions Analyzer – Free Active Directory ToolFree Permissions Analyzer for Active Directory

I like thePermissions Analyzer because it enables me to see WHO has permissions to do WHAT at a glance.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, and takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free SolarWinds utility saves when you are troubleshooting authorization problems for user’s access to a resource.  Give this permissions monitor a try – it’s free!

Download SolarWinds’ Free Permissions Analyser – Active Directory Tool

How to Create a .Reg File with Notepad

When you need to create your own .reg file, it is probably easiest to start with an existing file and modify its settings.  One way to obtain such a file would be to export a branch of the registry using regedit.  While it is easy to build your own .reg file, here is a reminder of a few simple syntax rules.

At the top, the file needs the name of the registry editor, for example:
Windows Registry Editor Version 5.00

Next comes a blank line.  Then follows the path enclosed in [square brackets]

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

Once we have defined the folder in the registry that we wish to amend, then we can specify the values, for example:

"DefaultUserName"="Guyt"
"DefaultPassword"="P@$sw0rd"
"DefaultDomainName"="cp"

Here is the completed .reg file as seen in notepad. As you save, remember the .reg file extension, for example Auto.reg.

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="Guyt"
"DefaultPassword"="Pa$sw0rd"
"DefaultDomainName"="cp"

 

Observe the rhythm of the REG_SZ syntax, "ValueName" = "string".  Obey the rules of the quotes, "Matching open and closing" speech marks.  In the case of hex numbers, known as REG_DWORD, precede the final value with dword: and don’t use speech marks for the right side of the equals sign, for example:

"ShutdownFlags"=dword:00000027 (Correct)
"ShutdownFlags"="dword:00000027" ("Wrong")

@ At symbol

As you get more experienced with .reg examples, you may discover the @.  Since the @ is found on the first line of the code proper, this is a clue that it means the default setting.  Thus rather than saying
Default="xmlfile"
The .reg file uses: @="xmlfile"

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.xml]
@="xmlfile"
"Content Type"="text/xml"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.xml\PersistentHandler]
@="{7E9D8D44-6926-426F-AA2B-217A819A5CCE}"
 

Summary – Creating .reg files

What I recommend is that you start learning the syntax and structure from an existing .reg file.  You can obtain this special file by exporting a branch of the registry with regedit.  Once you have an example .reg file, then pay close attention to the layout, start with the name of the Registry Editor Version, then a blank line, finally, the actual settings that you wish to merge with the registry.

Here are specific .reg examples.

If you like this page then please share it with your friends

 


Windows Vista Registry Tweaks: