How to Create Registry Script (.REG) Files

A: Modifying Windows Registry

Open Registry Editor, go to desired key and make changes.

Modify_Windows_Registry.png

B: Creating Registry Script File

Once you make changes, right-click on the registry key (which you modified) in left-side pane and select Export option.

Export_Registry_Script_Registry_Editor.png

It’ll open save dialog box to export the registry file. You just need to select the location to save the file and provide any desired name to the file. It’ll automatically create .REG file containing registry key information.

C: Editing Registry Script File

Now go to the folder containing registry script file which you created, right-click on the .REG file and select Edit option.

Edit_Registry_Script_Windows.png

It’ll open the registry script file in Notepad. The format of registry script will look similar to following:

Windows Registry Editor Version 5.00

[Registry_Key_Path]
String_or_DWORD_Name“=Value_data

Registry_Script_Structure.png

The “Windows Registry Editor Version 5.00” line is essential. It defines Registry Editor version and you don’t need to edit this line. Keep it as it is. In Windows 98 and Windows NT operating systems, the Registry Editor version was defined as REGEDIT4 in registry script files.

“Registry_Key_Path” is the full path of the required registry key enclosed within square brackets ([]).

Under registry key path, name of string/DWORD/etc is written within double-quotes (“”) and after the equal (=) sign its value is written.

D: Removing Data from Registry Script File

If you want to remove any key or string/DWORD value from registry script file, you can delete its line from the file. Remember if you want to remove any particular key from the file, also remove all string/DWORD values mentioned under it.

E: Combining Multiple Registry Script Files

You can join different registry script files. Edit the files in Notepad and copy/paste one registry script contents into other registry script file. Remember the line “Windows Registry Editor Version 5.00” should always appear only once and at the beginning of the registry script file.

F: Deleting Keys and Values from Registry Editor Using Registry Script File

“Export” option of Registry Editor only allows to create registry scripts which can add/modify registry keys and values. But if you want to create a registry script which can delete an existing key or value from registry, then you’ll need to modify the registry script.

First export the registry key and value which you want to delete from registry via registry script file. Then edit the registry script file in Notepad.

Now if you want to delete a key from Registry Editor, simply add minus/hyphen () sign before the key path. For example, if your registry script file contains following key path:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]

To delete “Explorer” key from Registry Editor, add minus/hyphen () sign before its path as shown following:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]

NOTE: Registry script will always delete the key from registry which is mentioned at the end of the path. In the above mentioned key path, “Explorer” key is mentioned at the end, so the line will only delete “Explorer” key from registry.

Delete_Key_Using_Registry_Script.png

If you want to delete a value from Registry Editor, you’ll need to add minus/hyphen () sign after equal (=) sign following the value name in registry script file. For example, if your registry script file contains following value:

“NoDriveTypeAutoRun”=dword:000000FF

And you want to delete “NoDriveTypeAutoRun” value from Registry Editor via registry script file, then do as following:

“NoDriveTypeAutoRun”=

Delete_Values_Using_Registry_Script.png

When you’ll run registry script, it’ll automatically remove the mentioned key/value from Registry Editor.

Source: [Guide] How to Create Registry Script (.REG) Files in Windows – AskVG