Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How to add, modify, or delete registry subkeys and values by using a .reg file
Article ID: 310516 - View products that this article applies to.
This article was previously published under Q310516
Important This 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:
322756This 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 a .reg file, the file contents merge into the local registry. Therefore, you must distribute .reg files with caution.
(http://support.microsoft.com/kb/322756/ )How to back up and restore the registry in Windows
RegistryEditorVersion is 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 line is 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.
RegistryPathx is 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:
[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.
DataItemNamex is the name of the data item that you want to import. If a data item in your file does not exist in the registry, the .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.
DataTypex is 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:
For more information about registry data types, click the following article number to view the article in the Microsoft Knowledge Base:
Collapse this tableExpand this table
256986DataValuex immediately 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.
(http://support.microsoft.com/kb/256986/ )Description of the Microsoft Windows registry
Note You can enter several data item lines for the same registry path.
Note the registry file should contain a blank line at the bottom of the file.
put a hyphen in front of the following registry key in the .reg file:
The following example has a .reg file that can perform this task.
[To delete a registry value with a .reg file, put a hyphen (-) after the equals sign following the DataItemName in the .reg file. For example, to delete the TestValue registry value from the following registry key:
put a hyphen after the "TestValue"= in the .reg file. The following example has a .reg file that can perform this task.
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.
regedit.exe /s path of .reg fileYou can also use Group Policy or System Policy to distribute registry changes across your network. For additional information, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms954395.aspxNote If the changes work, you can send the registration file to the appropriate users on the network.
Article ID: 310516 - Last Review: June 5, 2013 - Revision: 10.0