[Guide] How to Create Registry Script (.REG) Files in Windows
Today in this tutorial, we are going to tell you how to create .REG files also known as registry script files in Windows operating system. Registry script files are similar to batch scripts, they are used to modify Windows registry automatically. When you run a registry script file, it adds/removes/changes keys and values in Registry Editor (regedit.exe).
We here at AskVG, regularly share tutorials including various registry tweaks and troubleshooting tips which also provide ready-made registry scripts to do the task automatically. Registry scripts help Windows users in modifying registry quickly and easily without any requirement of registry editing experience.
Many times our readers ask us how do we create these registry scripts. Recently an AskVG reader “William Douglas” asked us similar question:
Advertisement
Hello! Question: Do you have a tutorial on how to write a reg file script? If yes, where is it? If no, can you point me to a source for this information?Background: I want to find or create a reg script to enable verbose messages. I can find lots of entirely adequate how-to info about that, but no ready-made scripts to run. Hence, my quest to learn how to write such file myself. Thank you!
So today we decided to post a tutorial to share the easiest way to create ready-made registry scripts in Windows quickly and automatically. Actually Windows operating system allows users to create registry script files using Registry Editor program.
If you also want to create registry script (.REG) files in any Windows version, following steps will help you:
Table of Contents
A: Modifying Windows Registry
First of all make the required changes in Registry Editor. For example, you want to create a registry script to disable drive autorun functionality in Windows as mentioned here.
So open Registry Editor by pressing WIN+R keys together to launch RUN dialog box and they type regedit in RUN box and press Enter. It’ll open Registry Editor. Now go to desired key and make changes.
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.
Advertisement
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.
Congratulations! You have made a registry script file yourself.
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.
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
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.
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"=-
When you’ll run registry script, it’ll automatically remove the mentioned key/value from Registry Editor.
That’s all for now. If you have any query regarding registry scripts, feel free to share it in your comment.
Also Check:
Hi is there a way to change the name of a registry entity?
^^ Right-click on the entry and select Rename option. But be careful while renaming anything in Registry. It may break your system.
Excellent script fixed the issue perfect
Is it possible to define variable inside the Registry Script file? Only for the use in this specific file, nothing more?
I working on a computer that has 100 registry entries that need to be changed. I need to change the serial number of the computer and all the associated installed programs. Instead of cut/paste each exported registry entry individually, can I write a script file that searches for the existing serial number and changes it to a new number?
I really appreciate this information. Thank you.
^^ You can give a try to various text editing software. Many software come with multi-file editing feature.