Running reg file from bat. Working with the Windows registry: how to run the regedit program on your computer? Removing registry items using a .reg file

We can say with 100% confidence that every user has encountered a situation where he needed to rename several files at the same time. Changing the name of each file individually is not the most interesting thing and certainly not the fastest. In such cases, it becomes necessary to find out how to rename multiple files at once and do it as quickly and efficiently as possible. This instruction will tell you how you can do this using several methods. It describes both built-in system methods and third-party applications.

How to rename multiple files at once in Explorer

Let's start with the simplest and most obvious method. This is done through Explorer and will prove effective for the vast majority of users.

Clue: After selecting several files, you can quickly rename them manually (if we're talking about only about a few objects). Click F2 , and after that use Tab to move to the next file.

How to rename multiple files at once via Command Line

The following method will be executed via Command Prompt and the appropriate command ren. Click Win+ R and enter cmd. Click Enter. After opening command line enter the path to the folder with the files you need. For example, to go to the Photos folder on drive D, you need to enter the following command:

CDD:\Photos.

To rename a single file you can use this command:

ren “file (1).txt” “new file.txt”

Please note: If a file contains spaces in its name, its name must be placed in quotes. If not, you don't need to use quotes.

It is best to use the Command Prompt to quickly change the extension of a large number of files. For example, you have a list of txt files that need to be converted into html. To do this, use the command:

ren*.txt*.html

The asterisk in this case serves as an indication that the file with any name should be renamed.

In addition, you can use the sign ? for other instructions. Team ren*html *.??? will remove the last letter of the extension from all HTML files. This will turn HTML files into HTM files. This principle can be used not only for extensions, but also for file names. Use it as you wish.

How to Rename Multiple Files at Once Using PowerShell

Compared to the Command Prompt, PowerShell provides much more flexibility when renaming a large number of files. Open the folder containing your files, hold down the button Shift and select Open PowerShell window here.

First, let's look at the process of renaming one file using the following example:

rename-item“file.extension” “new name.extension”

Easy enough, but renaming one file through PowerShell is a very strange thing, so let’s move on to group renaming. Let's look at this command as an example:

dir | rename-item -NewName ($_.name -replace “ ”,”_”)

Team dir collects all the files in the folder and “attaches” them to overall team renaming rename-item. Next $_. name indicates that you need to change the name for each file in the directory. - replace indicates to the system that one part of the name should be changed to another. The text in the first quotes is what needs to be removed, and what you put in the second quotes will appear in place of the deleted text.

This particular command removes spaces from file names and replaces them with underscores. Having learned how this command works, you can easily change file names in batches, without having to play with each file separately. Of course, you can add additional arguments that will complicate the renaming and make it more specific, but for this you will need to study in more detail the list of existing commands in PowerShell. If you know them, then most likely there is nothing for you to do in this instruction.

How to rename multiple files at once using third-party programs

PowerShell is not for everyone, because not everyone has the desire to learn commands and how they are structured. In this case, they rush to help third party utilities, which offer to rename multiple files at once using graphically friendly interfaces. Let's look at the Bulk Rename Utility as an example.

How to use Bulk Rename Utility

We must admit that an unprepared user can be intimidated appearance this application, which is more reminiscent of the console of complex equipment rather than a utility for changing the name of several files at the same time. However, the Bulk Rename Utility literally offers tons of different options that can only be used in PowerShell if you have well-developed Windows console text command skills.

At first glance, it seems that you can’t go without half a liter here. But in reality, everything is not so scary.

Yes, the interface of this utility is very complex, but its beauty is that all the changes you make are immediately displayed in the preview column. Thanks to this, you can literally study the application at random and see how this or that parameter affects file names. It should also be said that you can learn the basic principles of using this application and its interface in just a few minutes.

To get started, go to the official website of the application (it is completely free), download it and install it. If you don't want to install it, you can use the "portable version", but in this case you will not be able to integrate the application into the context menu, nor use BRU file associations. Choose what is more convenient and preferable for you.

In the screenshot above you can see what needs to be renamed large number text files whose names contain many words “-copy”. First you need to specify which text should be deleted. To do this, go to the section Replace (3) enter the required text. IN in this case *space* - copy. Field with remains empty. This way all files get a name New text document.txt.

Some files were left with brackets and numbers. To remove them, activate the panel Remove (5) and put a mark Digits. She is responsible for removing numbers from the name. To remove brackets, check Sym. It will remove any characters in the name, be it dashes, brackets, periods, and so on. You can also specify the deletion of individual characters or words. This is useful if you only need to remove certain signs, numbers, letters or words They must be entered in the fields Chars And Words. By the way, using this same section you can remove the words “copy” from the names.

Now all that remains is to add ordinal suffixes, since files of the same name and extension cannot be located in the same folder. Place a mark next to Numbering (10) and indicate Mode– Suffix. After this, each file will receive its own neatly decorated number.

Ultimately, the application window looks like this:

All you have to do is press the big button Rename, after which the chaotic set of files will be put in order. The application will warn you to check all files before applying changes, since you will not be able to rollback the changes you make. The only option is to use file history. Although when renaming files using standard system tools, the user has the opportunity to cancel the renaming, using the Bulk Rename Utility does not provide for rolling back the changes made.

Much better.

To get the most out of the app, you'll need to spend some time exploring it and exploring options that we didn't cover in this article. Yes, it will take both time and effort, but it is definitely worth it, especially if you often have to perform such tasks. If you don't like this application, you can also use the services of Advanced Renamer or Total Commander. Yes, the latter is such a hello from the 2000s, but this file manager includes quite powerful tools for mass renaming, so Total Commander can be useful in modern realities.

In this article we will look at the command line utility reg, which is responsible for working with Windows registry, for example, starting the registry from the command line or editing the registry from the command line. The registry itself contains the basic settings of the Windows system (user and application profiles); it is a kind of heart of the system. In fact, the registry is just a set of binary files; they cannot be opened, run or edited in a regular way, especially while the Windows system itself is running.

Or regedt32, is designed to view and edit the system registry and its contents, and launching or editing the registry from the command line is carried out using reg utilities .

Below is a list of the five root partitions and their short names:

  • HKEY_CLASSES_ROOT (HKCR),
  • HKEY_CURRENT_USER (HKCU),
  • HKEY_LOCAL_MACHINE (HKLM),
  • HKEY_USERS (HKU),
  • HKEY_CURRENT_CONFIG (HKCC).

To view registry keys using the command line, you need to write

reg query "SectionName"

The %SystemRoot%\system32\config folder contains five system files:

  • SYSTEM
  • SECURITY
  • SAM
  • SOFTWARE
  • DEFAULT

plus, in the Documents and Settings directory another “special” document is stored NTUSER.DAT. Editing or copying these resources using the standard method will not work - you need special utilities. However, you can back up the registry via the command line. To do this, you can use two functions - save and export. Let's start with the first one.

reg command line utility, save command

This command is useful at that moment if you need to save the registry, before, for example, editing the registry from the command line, so that in case of trouble it can be restored again. And so, the command itself has the following syntax:

reg save "SectionName" "FileName"

SectionName– specify the path to the partition to be saved, for example

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

File name– here indicates the path to the hive file (registry hive) that needs to be created; it must have the extension .hiv, for example: “C:\regsave\services.hiv”. If you need to work with a remote system, then it is worth remembering that only the HKLM and HKU branches are remotely accessible. If you encounter difficulties when trying to view registry keys using the command line on a remote machine, for example, after entering the command:

reg query \\192.168.1.6\HKLM

view the contents of HKLM on a computer with IP address 192.168.1.6, an error like “Access denied” or “path not found” appears, then you should check:

  • Is the “Remote Registry” service running on the remote machine (the command line offers the utilities net start “ServiceName” and net stop “ServiceName”)
  • Is the downtime open? general access: Folder properties, uncheck " Use simple file and folder sharing »
  • Check whether access to the computer is allowed at all.
  • Is the password used in account administrator, if not, then you should assign it ( Protection against empty passwords )

And, even after doing all this, it is quite possible that running the command will not produce results and access will be denied; executing the preliminary command helped me

tasklist /s 192.168.1.6 /u Username /p Password

here I launched t to view the running processes on the remote machine, using the administrator password, actually logged in, after which the manipulations went with a bang (I connected the remote registry of a Windows XP Sp3 machine from the Seven).

reg save HKLM\SYSTEM\CurrentControlSet\Services "C:\regsave\services.hiv"

If everything goes well, then after running the command the message “Operation completed successfully” will appear, and a proud hive file services.hiv will appear in the regsave directory. In order to return the previous appearance to the changed section, using a previously saved snapshot, you should run the command:

reg restore HKLM\SYSTEM\CurrentControlSet\Services "C:\regsave\services.hiv"

With high probability If you get an “access denied” error, most likely the system is using this branch and that’s why it’s busy. But to satisfy the desire for action, let's create a temporary partition:

reg add HKLM\SYSTEM\CurrentControlSet\Services\TEMP

here we added a temporary TEMP section to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services branch. If you enter the command

reg query HKLM\SYSTEM\CurrentControlSet\Services\TEMP

it’s clear that it’s still empty here. Now let’s run the restore command again, but edit the path where we will overwrite the data:

reg restore HKLM\SYSTEM\CurrentControlSet\Services\TEMP "C:\regsave\services.hiv"

Since the TEMP registry subkey created by the command line is not used by the system (we just created it), the data was successfully written there. Now, by entering the command

reg query HKLM\SYSTEM\CurrentControlSet\Services\TEMP

it can be seen that the contents of the entire service subsection were imported here. As a result of these actions, it is clear that misuse restore commands can simply clutter up your registry. Theoretically, to delete the TEMP subsection you need to enter the command:

reg delete HKLM\SYSTEM\CurrentControlSet\Services\TEMP

but in my case it said “access denied”, apparently the system has already taken some of the imported subsections into development, the rest can be easily removed individually.

reg command line utility, export command

There is a second way to make a snapshot of a specific registry via the command line. To do this, use the reg export utility; running it allows you to create “patches” - files with the .reg extension; quite often you have encountered them in computer games, until you run the “patch” to add information about the game to the system, the toy will not work. Positive side The thing about such files is that you just need to run them so that the information itself is written down where it needs to be. Launching the registry from the command line. Well, let's try to export the same Services subsection:

reg export HKLM\SYSTEM\CurrentControlSet\Services "C:\regsave\services.reg"

Registration files are used by merging the .reg file with the registry, done in Regedit. There are three ways to transfer the contents of this file to the registry.

  • Double-click on this file (the default action for a .reg file is merge).
  • Enter Regedit<имя_файла>.reg on the command line.
  • Select File\Import from the Regedit menu bar.

Advice. If you want to run .reg files from the command line in unmaintained mode, or want to create batch files that merge .reg files into the registry without user intervention, use Regedit command with the following syntax: Regedit /s<имя_файла>.reg.

When the .reg file is sent to the registry, the following actions occur.

  • If the path in this file is not specified, it is added.
  • If a data element does not already exist, it is added (along with its value).
  • If any data element already exists, its value is replaced with the value from the .reg file.

Log files are valid even if you have applied group policy, which disables registry editing tools (otherwise programs and the system would not be able to make changes to the registry if necessary).

You can distribute the .reg file via email or allow users to copy it from a shared network point during login (using some command in the login script). You can then provide each user with the ability to use it.

Example log file

As an example, here is the text of a .reg file that I merge on all computers on my network. It adds an option to the context menu for folders that allows you to open a command prompt window. I prefer to open a Command Prompt window for a specific location instead of using the CD command to navigate through a folder structure.

Windows Registry Editor Version 5.00

@="Command Window Here"

@="cmd.exe /k cd %1"

To create this .reg file by making changes to the registry and exporting the key, follow these steps in Regedit.

  1. Select the HKEY_CLASSES_ROOT\Directory\shell section.
  2. Create a new subkey named OpenNew.
  3. Open the Default data item in the right pane and give it the value Command Window Here. (This registry value represents the phrase that will appear in context menu, so you can replace the phrase with the way you want.)
  4. Create a new subkey named Command under the OpenNew subkey.
  5. Open the Default item under Command and enter cmd.exe /k cd %1.
  6. Select the OpenNew subkey and select File\Export to create a .reg file that contains these new subkeys along with their data.

If you have multiple drives on your computer, you can add similar command to the context menu that appears when you right-click on a drive in Windows Explorer or My Computer. The same steps are followed as when creating a command for folders, with the following changes.

  • Use the HKEY_CLASSES_ROOT\Drive\shell section as your starting point.
  • For the Default data item in the HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command subkey, enter cmd.exe /k.

Export the HKEY_CLASSES_ROOT\Drive\shell key and distribute this .reg file to all users who would like to use this handy tool.

Removing registry items using a .reg file

You can also use the .reg file to remove subkeys and data items. It's so simple that it even causes concern.

  • To delete a subkey, enter a minus sign at the beginning of the subkey's name.
  • To delete an individual data item, enter a minus sign in place of its value ("Data_Element_Name=-").

Registry Security Features

Working with the security features for the registry is very similar to working with the security features you get with the NTFS file system. You can apply access permissions to sections and subsections at the group or user level, determine whether you want permissions to be inheritable, and create an entire hierarchy of permissions with any level of refinement. In other words, just like in NTFS, each registry key has its own ACL (access control list).

By default, the registry security levels are set to fairly strict. Administrators have full access to the entire registry, but other users only have full access to the keys that apply to their own user accounts (this includes HKEY_CURRENT_USER), and read-only access to keys that belong to this computer and installed software. However, you may need to change registry security settings to grant or revoke permissions at the group or user level. This section describes the tasks associated with setting permissions.

Description of authority

The permissions you can apply to a specific registry key are available at two levels.

  • Basic powers, which are made up of individual powers.
  • Separate powers.

Basic powers are a group of individual (more specific) powers. For most partitions, the basic permissions are Full Control and Read.

Selected powers are shown in Table 4.2. All permissions in Table 4.2 are granted to users who have Full Control permissions. Permissions that do not fall into the Read group (third column of Table 4.2) are called special powers.

Table 4.2. Permissions applied to registry keys
Authority Description Included in basic Read permissions?
Query Value Viewing the value in a data item Yes
Set Value Changing a value in a data item No
Create Subkey Creating a subsection No
Enumerate Subkey View all subsections Yes
Notify Receive or set audit notifications Yes
Create Link Create a link to another section No
Delete Deleting a section (and subsections) No
Write DAC Changing DAC permissions No
Write Owner Change of owner No
Read Control Reading the ACL Yes

Working with Permissions

To view or set permissions for a registry key (including top-level subtrees), right-click on this key and select Permissions from the context menu. A Permissions dialog box for this section will appear, similar to Figure 4.2.

Rice. 4.2. Basic permissions for groups and users are presented in the Permissions dialog box

As you select each user or group, you see the permissions. Permissions that are grayed out are inherited from parent sections and cannot be changed in this dialog box.

At some point while working on a PC, each user may need to make changes to the Windows registry. The most trivial example is that the language bar has disappeared and to restore it you need to find and run regedit.exe on the computer. Perhaps for advanced users such an action will not cause any problem, but for beginners such advice will instantly respond with the phrase “it’s easy to say, but how to do it?” Indeed, how to run regedit on a computer? It's actually very simple - just use one of 4 simple methods.

Option number 1: Launch the registry editor through the “Start” system menu

Perhaps this is the most convenient and simplest method that can be used to open regedit on absolutely all computers, regardless of the version of the Windows operating system installed on them. True, depending on the system interface, the actions will differ slightly:

Option #2: Launch regedit using Windows Explorer

You can also get started with the Registry Editor by using the operating system explorer. To do this, open “My Computer”, select Local disk C, and in it the Windows folder. In the contents of the folder we find regedit and launch it by double clicking the mouse.

Option #3: Launch the Windows Registry through the built-in search bar

On a PC with operating system Windows system 7, you can start regedit using the search form built into the top of the folder menu. In this case, just go to the “My Computer” section, enter Local Drive C, enter the name regedit in the address bar and press Enter. The system itself will search and show the access file to the registry editor.

It may be that the system detects several files with regedit in their name. This is not something to be afraid of. We simply find among them the one that is located on drive C in Windows folder and is called regedit. To launch it, double-click on it with the mouse, in principle, nothing complicated.

Option number 4: Open the Windows registry through the “Run” command

What's different about this way of launching Registry Editor? The speed of task completion, since to start the program it is enough to perform only 3 steps:

In general, this option for launching the registry is suitable for use on computers with any operating system from Microsoft. However, on computers running Windows XP, you can also take advantage of its internal interface to do this.

In this case, use any of the methods described above to open the “Start” menu, find the “Run” item and click on this tab with the left mouse button. After this, the same standard Windows utility “Run” will open. Now all that remains is to enter the value regedit in the empty search field and click OK. As a result, the registry editor will start and be ready to work - everything is very simple.

Thus, find and launch the Windows registry ( regedit program, Registry Editor) is quite easy. You just need to choose one option you like from the 4 described above and feel free to start making the system settings you need.


These are small files that quietly do their job, allowing the computer to function normally and perform its tasks. If the system files are damaged, then the operating system itself begins to work with errors (“glitchy”).

In the worst case scenario, this could cause Windows to stop working completely. This does not happen often, and there are several reasons why system files become damaged. One of them is the incorrect actions of an inexperienced user who, overestimating his strength, tries to tune the operating system without having either knowledge or experience.

Therefore, I want to warn you right away - if you do not know what you are doing and what consequences this may lead to - DO NOT edit system files or delete them. In principle, this applies to any files with an extension unknown to you.

Let's start looking at system files with the reg file. Because these are the files that users often encounter. Despite this unusual extension, this is actually an ordinary text file. The reg extension tells the operating system that this file contains registry keys and certain settings.

See below what the reg file looks like.

All information is clearly structured for ease of computer processing. So, for example, the required first line REGEDIT with the required parameter tells the computer for which version of the Windows OS the reg file is intended for. Next, in a certain order, are the registry keys and their parameters.

By the way, I have written an article using this file more than once. For example, " "

What is the reg file for?

The main purpose of this type of service files is to work with registry keys. This is the easiest way to create or replace the necessary keys. In an applied sense, the reg file is used to create, store or change user settings. With it, you can quickly and easily transfer settings from one computer to another or create a backup copy so you can restore them in the future.

Working with such files is quite simple. To bring in necessary information to the operating system registry, open the reg file, and click “Yes” twice - agreeing to the changes that will be made to the registry. Next, Windows will automatically create the required request, process it and enter the data into its registry.

How to work with reg file

Since, as I mentioned earlier, the reg file is essentially an ordinary text file, then the best remedy Programmers have not yet come up with a way to work with it other than notepad. You can use a standard Windows notepad or its equivalent. Based on own experience, I can safely recommend using the Notepad+++ program. Firstly, it is free, and secondly, it has a lot of additional features.

Editing itself is no different from working with any text. To save changes, just save the file again using the “File” - “Save As...” command or the hotkey configuration “Ctrl” + “S”.

Creating a file with the reg extension is also done using the standard procedures “File” - “Create” or the hotkey configuration “Ctrl” + “N”. In addition, you can create a reg file using standard procedure exporting data from the registry.

In conclusion, I would like to note that working with such files does not cause problems for an experienced user. I would especially like to emphasize “ from an experienced user" If you are just starting to master your computer, I strongly recommend that you do not experiment with the registry. Because, as practice shows, in most cases such experiments lead to the need to restore the operating system. But you will agree that you hardly need this.