Vista Registry - How to Create .Reg FilesVista Registry - How to Create .Reg FilesThis 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 FilesThe 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 filesThe 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
Open the .Reg File With NotepadBeware, 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
. Dissecting the .Reg FilesRegistry 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: 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: 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. 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 delete the value called
DefaultPassword append equals and then minus, like this:
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. Registry Types 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. How to Create a .Reg File with NotepadWhen 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: Next comes a blank line. Then follows the path enclosed in [square brackets] Windows Registry Editor Version 5.00
Once we have defined the folder in the registry that we wish to amend, then we can specify the values, for example:
"DefaultUserName"="Guyt" 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
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) @ At symbolAs 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
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 filesWhat 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.
Watch a Vista Training Video Demo. Windows Vista Registry Tweaks:
^
|
|||||