When making changes to the Windows Registry, you can open the Registry Editor and edit the keys and values that need to be configured. But what if you need to make a lot of changes at once? When this happens, entering them one at a time can get tiresome pretty quickly.
However, with a registry file, you can apply multiple changes to the Windows registry at the same time. You just need to know how to create a registry file and what lines to put in it.
So, what is a Windows registry file and how do you create and use it? Here’s what you need to know to get started with these powerful files.
What is a Windows registry file?
A registry file is a file used to update the Windows registry by adding, editing, or deleting keys and values. It’s a text file with a .reg extension, so you might also hear people refer to them as REG files.
How to create a .reg file with Notepad
If you want to create a .reg file from scratch, you can use a text editor like Notepad. To do this, you need to know the basic structure of the registry file.
If you don’t know what a registry file looks like, don’t worry; we will help you in this process. So download Notepad and let’s get started.
For this guide, we are going to create a registry file that will follow the steps in our guide on how to add “Boot to Advanced Startup Options” to the context menu.
The first line of the .reg file is the version of the registry editor you are using. Here is the version we entered in Notepad.
Windows Registry Editor Version 5.00
Next, we are going to add the file path for the key we want to change, but it must be enclosed in square brackets. If the key is not available, Registry Editor will create it. To do this, enter the following text in Notepad:
Next, we create an entry and change its value. You must specify the data type of an entry before assigning a value to it. Here is the structure of the string to be entered:
We’re going to create a string value, and here’s what the actual string will look like in Notepad:
“MUIVerb”=“Boot to Advanced Startup Options”
If we are going to add another value to the key, we must add it directly below the last line. Like this:
If you are going to add another key and associated values, you will also need to provide the path to that key and then enter the values. To complete the REG file we’re creating, we’ll add a new key and value:
@=“shutdown.exe /r /o /f /t 00”
Do not confuse with @ sign in the last line, as it means we are editing (Default) string value in team key.
So, the final REG file in Notepad should look like the screenshot below.
You can add as many keys and values to a REG file as you like.
Now click Ctrl + C or click File > Save. Then give the file a name, make sure it has a .reg extension, and click Save.
You are now ready to run this registry file so that the keys and values are merged into the registry.
How to use the registry file you created
Registry editing is an advanced way to make changes to your Windows PC. Therefore, before doing anything about it, we recommend creating a system restore point. If you hack the registry, there is a chance that you can also break Windows, and so it’s always good to have some kind of backup that you can use to restore your system.
To open the generated REG file, navigate to its location, double-click it, and click Yes at the UAC command line. You will then receive a warning asking if you are sure you want to continue. Since we know what we’re doing, we’ll just go ahead and press Yes.
You will then receive a message that Registry Editor has successfully added the keys and values contained in the .reg file to the registry. Click GOOD to close the message.
You can also import a .reg file by opening the Registry Editor and clicking File > Import in the upper left corner.
In the dialog box, select the created registry file and click open perform the merge. You will receive a message that the keys and values were merged successfully. Click GOOD to close it.
When you open the Registry Editor and navigate to the keys specified in the REG file, you will see that all the keys and values are there.
If you’d like to see another example where we modify the Windows Registry using a REG file, check out our tutorial on adding the “Create System Restore Point” option to the context menu.
How to Export and Edit a REG File in Windows
You don’t always need to create a .reg file from scratch. You can also export an existing key using the Registry Editor and update the keys and values of the resulting registry file in Notepad.
To do this, click Win + P to open the Run Windows dialog, type regedit, and press GOOD. Click Yes at the prompt from UAC and in the registry editor, right-click on the key and select Export.
In the Save dialog box, give the .reg file a name, choose a location to save it, and click Save. After the Registry Editor creates the REG file, you can edit it with a text editor like Notepad or a code editor like VSCode.
How to remove a key in the Windows registry using a .reg file
An easy way to delete a key in the registry is to do it directly in the registry editor. But if there are a lot of them, you can just use the registry file. Continuing with the example above, here’s what the registry file would look like:
Windows Registry Editor Version 5.00
Here we have just removed all AdvancedStartup key by putting minus sign at the beginning of the file path.
Now you know how to create registry files in Windows
You can simplify the process of customizing the Windows registry by using .reg files. Once you learn how to create or edit them, you can take your Windows customization skills to the next level. Gone are the days of tedious adding keys and values to the registry one by one using the registry editor.
Of course, this guide only scratches the surface of what you can do with REG files, so consider it a starting point.