syntax, reg file structure​


____________________
what is a reg file?
This is a file that contains information for interacting with registry elements.

Attention!
before you do anything, be sure to do it backup copy registry!!!

___________________________________________________

So, the most common tool for working with the registry is the utility regedit.

With its help we can perform all the necessary operations.
Creation, modification, saving, import, export, deletion and other operations with system registry objects.

Shall we try?
Let's create our own command in the context menu.
To do this, open the section

Code:

HKEY_CLASSES_ROOT\DesktopBackground\Shell

Create a section called name.
there is another section in it - command.

In chapter name-create a string parameter - reg_sz
and give it any value - for example

Code:

My first bullshit...

My sick imagination got sick of this name, you are free to choose yours...

And in the section command create a similar string parameter with the name of the command to be executed.
It got into my head regedit.exe
As a result, we got when pressing right click mouse and the following context menu command:

By clicking we call up the registry editor...

You can simplify your task by using registry tweak.

Yes...
You don't have to mess around with registry editor, and just add it to the registry necessary information using a file with the extension .reg

What does this look like in practice?

If all the described operations write to reg file, then we get the following:

Code:

Windows Registry Editor Version 5.00 @="my first garbage..." @="regedit.exe"

To create a reg file, any text editor.
I took the notepad.
So, let's create a new test document.
In the previous example, we added new settings and keys to the registry.
Let's remove them now.
To do this, enter in a text document:

Code:

Windows Registry Editor Version 5.00 @="my first bullshit..."=- [-HKEY_CLASSES_ROOT\DesktopBackground\Shell\name\command] @="regedit.exe"

Save as - all files - name with extension .reg (for example tweak.reg)
Double click on the received file, apply, ok.
Let's look at the registry and see that the command section has been deleted, and in the name section the parameter that we previously created has been deleted.
Now it's time to figure out the syntax.

Code:

Windows Registry Editor Version 5.00

required line - indicates the editor version.

Registry_editor_version - either "Windows Registry Editor Version 5.00" for Windows 2000, Windows XP and Windows Server 2003, or “REGEDIT4” (letters must be capitalized) for Windows 98 and Windows NT 4.0. The REGEDIT4 header can also be used on computers running Windows 2000, Windows XP, and Windows Server 2003.

2)
The next line must be empty.

Code:

Note:
If the partition does not exist, it will be created.
If it exists, the parameters or changes contained in the tweak will be added to it.
In other words, the element will be overwritten.

4)
Parameter name is the name of the data parameter being imported. If a file's data element is not in the registry, the REG file adds it (with a value). If the data item exists, the value in the REG file overwrites the existing value. The data element name is enclosed in quotation marks. The data item name is followed by an equal sign (=).

5)
Value, parameter type

Reg file structure
Chebotarev Igor

Knowledge Windows registry It won't be complete without the ability to write a reg file. Let's start with what it is. A reg file is a file that has a specific structure and contains information that can be imported into the registry. If work with the registry editor has been blocked (you can read how to do this in the article), then the easiest way to edit the registry is to create and import a reg file (of course, you can go into DOS, into protected mode, use other programs, but that’s all much more difficult, and most importantly longer).
Reg files have certain structural requirements. Let's start with the fact that in the first line of the file you must enter
REGEDIT4
Please note that the letters must be large. Apart from this, there should be nothing in the first line. There MUST be an empty line after this text. Then, the registry section is indicated in which you need to register or change some parameters. The section title must be enclosed in square brackets [...]. Below are the parameters that need to be added, one parameter per line. If you need to make changes in several sections, then you should leave one blank line between last parameter the previous section and the name of the next section. Might be a little confusing, but here's what it should look like:
REGEDIT4
"param1"="znachenie1"
"param2"="znachenei2"
"param3"="znachenie3"
"param_1"="znachenie_1"
The last line in the file must be BLANK. Once you have created such a file, simply run it as a regular program, you will be prompted to make changes to the registry, and after a positive answer, the information from the file will be imported. Windows will report the import results in the window that appears after this.
Now a few words about the parameters that can be added. As you may have noticed, the example above adds parameters using lines like "param1"="znachenie1". Those. This adds a STRING parameter with the name "param1" and the value "znachenie1". But there are also binary and DWORD parameters. The recording format for adding them is slightly different. For DWORD type parameters the string is used
"param"=dword:XXXXXXXX
Here "param" is the name of the parameter, dword - indicates the type of this parameter (the letters must be small!) and after the colon there is a value of eight digits in hexadecimal (!) format. However, most DWORD parameters have a value of either 0 or 1, which means you should write either 00000000 or 00000001 instead of XXXXXXXXX. Spaces are not allowed in the line.
To add a binary parameter, the recording format is slightly different:
"param"=hex:XX,XX,XX,....
Now I will decipher this line. Well, everything is clear with the name of the parameter, after the "=" sign there is a hex, i.e. indicates that this will be a binary parameter, followed by hexadecimal numbers separated by a comma. For example, if you need to add a binary parameter equal to "be 00 00 00", then you write the line
"param"=hex:be,00,00,00
There are "Default" parameters in the registry. To assign them some value through a reg file, you need to add the following line:
@="znachenie"
Here the @ symbol indicates that we are assigning the value of the parameter to "Default". Note that it is not enclosed in quotation marks.
Now I will give an example of a simple reg file that registers a site in the registry that sets the home page in Internet Explorer:
REGEDIT4
"Start Page" = "http://www.site/"
In my opinion, everything is very simple and clear. But reg files have one peculiarity: they cannot be used to delete parameters in the registry, although you can delete an entire section. To remove a section from the registry, place the “-” symbol in square brackets before its name. This is what it looks like:
[-HKEY_LOCAL_MACHINE\Software\QuickSoft\QuickStart]
Thanks to this entry, the "QuickStart" subsection from the "QuickSoft" section will be removed with all its contents. However, what about the parameters? After all, they cannot be deleted. Thus, setting restrictions on access to various settings Windows shell, as described in the article, is done using DWORD type parameters. In this case, if the parameter value is 1 (00000001), then the limitation is enabled, and if it is 0 (00000000), then the limitation is disabled. Thus, it is not necessary to delete the parameters; it is enough to simply assign them values ​​equal to zero.
Note regarding deletion made by Nikolai Basmanov:
Using REG files you can delete parameters. Syntax:
REGEDIT4
"xxx"=-

Here, perhaps, is all the basic information on the structure of reg files. I also recommend trying to export some sections from the registry (not very large with small nesting) in order to once again look at the file structure. It never hurts. Now you can easily make changes to the registry using reg files.

So, how to create a file with the extension . reg?

Let's look at everything in order. First, we need to make sure that in Windows XP/Vista/7/8 the function for hiding extensions of registered file types is disabled. Next we will show you how to do this (see below):

1) Click Start and choose Control Panel

2) In the window that appears, select Design and personalization(after setting in the line View: category)

If you have set the parameter large or small icons:

then we're just looking Folders settings Let's go straight to point 4.

4) You will see this window:

Go to the tab View, scroll the list to the very end and look for the line Hide extensions for registered file types, and uncheck the box.

Click OK and close all previous windows. Now we see file extensions. For example, a text document will have the extension .txt at the very end of its name.

5) Now let's start creating reg file

Right-click on the desktop (or any folder)

V context menu choose Create ---> Text Document

You can make changes to the registry by entering new values ​​for the desired parameters in the registry editor itself or using import. But there is another way. You can prepare a file in a given format in advance, and the necessary parameters will be automatically installed in the registry. For these purposes they are used text files with extension reg .

REG file format

This is what an example REG file looks like that will allow you to create a partition( Test) with parameters ( "CatName").


;Set new parameters for the Test section

"CatName"="reestr"
"CatAge"=dword:00000008

REG File Syntax

Let's look at the REG file format. The file header comes first

Windows Registry Editor Version 5.00

It should be noted that in earlier operating systems, Windows 98 And Windows NT 4.0, header used REGEDIT4. If you still have similar old files, don’t be alarmed. will understand this file and process the information correctly. And here reverse process will be unavailable - Windows 98 will not be able to recognize the new header and will throw an error. One important detail is that after the title there must be an empty line.

If you need to include a comment in the document so as not to forget about the purpose of the parameter, then put the symbol at the beginning ";" (semicolon). The comment is for the convenience of the user and is not entered into the register.

Creating a REG file

Write REG file You can use any text editor, for example Notepad. Create a new one Text Document, type the above code (Fig. 1.1) and save the file with the REG extension. If you want to practice creating such files, it is easier to generate them by exporting from the Registry Editor, and then make changes in Notepad.

Rice. 1.1.

Making changes to the registry using a REG file

Above we have already examined the behavior of the system when double-clicking on a file with the extension .reg. At double click on REG file you start the registry editor, to which the file name is passed as a parameter.

ATTENTION
Before importing into the registry REG file Be sure to make a registry backup or system restore point! This method not very convenient for automating tasks. For example, we want to create a script automatic installation systems using REG-files. If there are too many such files, the user will constantly have to press the button OK, which, you see, will not give him pleasure. You can suppress the appearance of the dialog box by running the command with the parameter /S:

REGEDIT /S D:\test.reg

This is the method used by programmers and system administrators when creating your programs and scripts using REG files. True, the account control service Windows entries will prompt you to allow the operation, but the control service can be disabled for the duration of such actions, and then the user will not see anything. With the help REG file you can also delete partitions. To do this, you need to put a minus sign in front of the section name. Let's open our file in Notepad cat.reg and make the following changes:

Windows Registry Editor Version 5.00
:put a minus sign to delete a partition
[-HKEY_CURRENT_USER\Software\Test]

Now you need to double click on the REG file to run it and import the entries into the registry. Check in Registry Editor that the specified key has been deleted.

ATTENTION
Please note that you can only delete sections that do not contain subsections. Otherwise, you need to sequentially delete all subsections included in it and only then proceed to delete the desired section.

You can also remove the parameter. To do this, place a minus sign (-) after the equal sign (=).

Greetings, in this article I will show you how to create a registry file yourself, which will be called upon to make changes to this very registry without manually navigating and editing it.

I think almost every one of you who found yourself on this page was faced with the need to make amendments to Windows. Or perhaps this was done as an experiment when adding/making adjustments to the appearance of the system.

Agree, it is much more pleasant to take advantage of the opportunity to do without a long search for the required registry section/hive in order to change required parameters. And if you have learned the basics by making fun of friends and colleagues, then you can’t do without automated changes to the registry.

How to create a registry file? A little preparation...

All that is required of us is

  • force Windows to display files that enter the system. This is done in Folder properties after withdrawing the “check” opposite the item Hide extensions for registered file types:
  • get additional text editors like or Notepad++. But for starters, the built-in Notepad is also suitable.

How to create a registry file. Go…

Registry files are simple text files that obey the familiar letters of the Latin alphabet and mathematical symbols. But in order for the registry itself to recognize our files, we need to give the written form an appropriate appearance. That is, two conditions must be met:

  • the file must have its own .reg
  • and in the title of the document (the first line that Windows will see) there should be a standard line belonging to the Windows Registry Editor. She is already unchanged for a long time:

Skip a line with a key Enter. And now in the line we write the path to the necessary parameters, keys, sections, enclosing it in square brackets(Necessarily). Here, by the way, you are free to specify any entry - if you came up with it, Windows will still create it, even if it is rubbish.

But we don’t need nonsense, and we will practice on useful changes in the system. There are plenty of them in the article “” - there are plenty of them useful functions, which will appear or disappear after changes to the registry. I'm working on this article all the time, so check back from time to time...

EXAMPLE. CHANGE THE EXISTING PARAMETER VALUE

In the article linked above, I show how to speed up the computer shutdown time by reducing the time it takes to close individual programs. To do this we change the parameter WaitToKillServiceTimeout in section:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control

giving the parameter a value of not 12000 (12 sec.), as it is by default - we are no longer interested in the current value - but the new one, say, reducing it to 10000 (10 sec.).

Well, let's write it like this in our file:

the path is in square brackets, remember?

In the new line we need to indicate what we want to do with the EXISTING parameter WaitToKillServiceTimeout:

don't miss the characters And =

And you can specify as many such lines as you like using Enter. All. Close the file, saving changes and naming the right name, replacing the extension while saving the changes. txt on the. reg:

The shortcut icon immediately changes from “text” to a shortcut belonging to the registry file:

How to create a registry file. How to create a new parameter?

Nothing difficult either. We also open a text editor (I didn’t close the previous one and continue to fill out the file). Line

Windows Registry Editor Version 5.00

on the spot. I use the Enter key to go down a couple of lines and enter new values. Now I will create new parameter. For example, if in the section:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Personalization

create parameter dword With name NoLockScreen and set it to “activate” – 1 , then you will need to create a registry file with the following script:

pay attention to the new symbols

  • = – assign characteristics
  • dwordparameter name
  • : - with meaning...
  • 00000001 …included

How to create a registry file. We delete the parameter.

In order to delete a registry value, we use the same syntax as in the paragraph above, only immediately after the “assign” symbol = you need to add a mathematical symbol “remove” or “minus”. Take a look:

The parameters in the registry are different, as are their semantic purposes. They depend on the type of parameter (string, binary, multistring, etc.), as well as on the system bit depth (DWORD, QDWORD).

In the next article we will look at how

What else... Let me remind you that it is better to practice all operations with the registry on virtual machine, and then in your system after.

I wish you success.

Read: 1,295