ImportantThis section, method, or task contains steps that tell you how to modify the registry. however, serious problems might occur if you modify the Registry incorrectly. therefore, make sure that you follow these steps carefully. for added protection, back up the registry before you modify it. then, you can restore the registry if a problem occurs. for more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756How to back up and restore the Registry in Windows
This step-by-step article describes how to add, modify, or delete registry subkeys and values by using a registration entries (. reg) file. regedit.exe uses. reg files to import and export registry subkeys and values. you can use these. reg files to remotely distribute registry changes to several Windows-based computers. when you run. reg file, the file contents merge into the local registry. therefore, you must distribute. reg files with caution.
Back to the topSyntax of. Reg files
A. reg file has the following syntax:
Registryeditorversion
Blank line
[Registrypath1]
"Dataitemname1"="Datatype1:Datavalue1"
Dataitemname2"="Datatype2:Datavalue2"
Blank line
[Registrypath2]
"Dataitemname3"="Datatype3:Datavalue3"
Where:
RegistryeditorversionIs either "Windows Registry Editor Version 5.00" for Windows 2000, Windows XP, and Windows Server 2003, or "regedit4" for Windows 98 and Windows NT 4.0. the "regedit4" header also works on Windows 2000-based, Windows XP-based, and Windows Server 2003-based computers.
Blank lineIs a blank line. this identifies the start of a new registry path. each key or subkey is a new registry path. if you have several keys in your. reg file, blank lines can help you to examine and to troubleshoot the contents.
RegistrypathxIs the path of the subkey that holds the first value you are importing. Enclose the path in square brackets, and separate each level of the hierarchy by a backslash. For example:
[Hkey_local _ machine/software/policies/Microsoft/Windows/system]
A. reg file can contain several registry paths. if the bottom of the hierarchy in the path statement does not exist in the registry, a new subkey is created. the contents of the registry files are sent to the registry in the order you enter them. therefore, if you want to create a new subkey with another subkey below it, you must enter the lines in the correct order.
DataitemnamexIs the name of the data item that you want to import. if a data item in your file does not exist in the Registry,. reg file adds it (with the value of the data item ). if a data item does exist, the value in your. reg file overwrites the existing value. quotation marks enclose the name of the data item. an equal sign (=) immediately follows the name of the data item.
DatatypexIs the data type for the registry value and immediately follows the equal sign. for all the data types other than REG_SZ (a string value), a colon immediately follows the data type. if the data type is REG_SZ, do not include the data type value or colon. in this case, regedit.exe assumes REG_SZ for the data type. the following table lists the typical registry data types:
Collapse this tableexpand this table
Data Type |
Datatype in. Reg |
REG_BINARY |
Hexadecimal |
REG_DWORD |
DWORD |
REG_EXPAND_SZ |
Hexadecimal (2) |
Reg_multi_sz |
Hexadecimal (7) |
For more information about registry data types, click the following article number to view the article in the Microsoft Knowledge Base:
256986(Http://support.microsoft.com/kb/256986/) Description of the Microsoft Windows Registry
DatavaluexImmediately follows the colon (or the equal sign with reg_sz) and must be in the appropriate format (for example, string or hexadecimal). Use hexadecimal format for binary data items.
NoteYou can enter several data item lines for the same Registry path.
NoteThe Registry File shoshould contain a blank line at the bottom of the file.
Back to the topAdding registry subkeys or adding and changing registry values
To add a registry subkey or add or change a registry value, make the appropriate changes in the Registry, and then export the appropriate subkey or subkeys. exported registry subkeys are automatically saved. reg files. to make changes to the registry and export your changes to. reg file, follow these steps:
- ClickStart, ClickRun, Type Regedit inOpenBox, and then clickOK.
- Locate and then click the subkey that holds the Registry item or items that you want to change.
- ClickFile, And then clickExport.
This step backs up the subkey before you make any changes. You can import this file back into the registry later if your changes cause a problem.
- InFile NameBox, type a file name to use to save the. reg file with the original registry items, and then clickSave.
NoteUse a file name that reminds you of the contents, such as a reference to the name of the subkey.
- In the right pane, add or modify the registry items you want.
- Repeat steps 3 and 4 to export the subkey again, but use a different file name for the. reg file. You can use this. reg file to make your registry changes on another computer.
- Test your changes on the local computer. if they cause a problem, double-click the file that holds the backup of the original registry data to return the Registry to its original state. if the changes work as expected, You can distribute. reg you created in Step 6 to other computers by using the methods in"Distributing Registry Changes"Section of this article.
Back to the topDeleting registry keys and values
To delete a registry key with a. reg file, put a hyphen (-) in front ofRegistrypathIn the. reg file. For example, to deleteTestSubkey from the following registry key:
HKEY_LOCAL_MACHINE/software
Put a hyphen in front of the following registry key in the. reg file:
HKEY_LOCAL_MACHINE/software/test
The following example has a. reg file that can perform this task.
[-HKEY_LOCAL_MACHINE/software/test]
To delete a registry value with a. reg file, put a hyphen (-) after the equals sign followingDataitemnameIn the. reg file. For example, to deleteTestvalueRegistry value from the following registry key:
HKEY_LOCAL_MACHINE/software/test
Put a hyphen after the "testvalue" = in the. reg file. The following example has a. reg file that can perform this task.
HKEY_LOCAL_MACHINE/software/test
"Testvalue" =-
To create the. reg file, use regedit.exe to export the registry key that you want to delete, and then use NotePad to edit the. reg file and insert the hyphen.
Back to the topRenaming registry keys and values
To rename a key or value, delete the key or value, and then create a new key or value with the new name.
Back to the topDistributing Registry Changes
You can send. reg file to users in an e-mail message, put. reg file on a network share and direct users to the network share to run it, or you can add a command to the users 'logon scripts to automatically import. reg file when they log on. when users run. reg file, they receive the following messages:
Registry Editor
Are you sure you want to add the information in Path of. reg fileTo the registry?
If the user clicksYes, The user defined es the following message:
Registry Editor
Information in path of. reg file has been successfully entered into the registry.
Regedit.exe supports/SCommand-line switch to not display these messages. For example, to silently run the. reg file (with/SSwitch) from a login script batch file, use the following syntax:
Regedit.exe/s Path of. reg file
You can also use group policy or system policy to distribute registry changes login SS your network. For additional information, visit the following Microsoft Web site:
Http://msdn2.microsoft.com/en-us/library/ms954395.aspxHttp://msdn2.microsoft.com/en-us/library/ms954395.aspx)
NoteIf the changes work, you can send the registration file to the appropriate users on the network.