SoFunction
Updated on 2025-03-09

Detailed explanation of the use of Reg commands, a batch operation registry is required

reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000
reg add HKLM\SYSTEM\CurrentControlSet\services\NlaSvc\Parameters\Internet /v EnableActiveProbing /t REG_DWORD /d 1


2. reg delete delete key or child key from the registry
Syntax:reg delete KeyName [{/v EntryName|/ve|/va}] [/f]
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU and HKCC.
/v EntryName
Delete specific items under subkeys. If no item is specified, all items and children under the child will be deleted.
/ve
Specifies that only entries with null values ​​can be deleted.
/va
Delete all items under the specified child. Use this parameter to delete children under specified children.
/f
Delete an existing registry subkey or key without requesting confirmation.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg delete operation. Value description
0 Success
1 Failed

example
The following example shows how to use the reg delete command:
cmd /k reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\" /f (The task manager in the taskbar is grayed out)
cmd /k reg delete "HKLM\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg" /f (delete unchecked items in MSConfig startup)
cmd /k reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\" /f (Delete CTFMON's mirror hijacking)
cmd /k reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify" /v IconStreams /f
cmd /k reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify" /v PastIconsStream /f (delete the history of the notification area)

 3. reg compare the specified registry subkey or key
Syntax:reg compare KeyName1 KeyName2 [/v EntryName | /ve] {[/oa]|[/od]|[/os]|[on]} [/s]
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU and HKCC. If you specify a remote computer, only HKLM and HKU subdirectory trees can be used.
/v EntryName
Compare specific items under child items.
/ve
Specifies that only items that do not have values ​​can be compared.
{[/oa]|[/od]|[/os]|[on]}
Specifies how different points and matching points are displayed. The default setting is /od. Value description
/oa specifies that all different points and matching points are displayed. By default, only the differences are listed.
/od specifies that only different points are displayed. This is the default action.
/os specifies that only matching points are displayed. By default, only the differences are listed.
/on specifies that nothing is displayed. By default, only the differences are listed.
/s Separator
Compare all children and items.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg compare operation. Value description
0 The comparison is successful and the results are the same.
1 Comparative failure.
2 Compare successful and find the difference.

example
The following example shows how to use the reg compare command:
reg compare "hkcu\software\microsoft\winmine" "hkcu\software\microsoft\winmine" /od /s

4. reg copy Copy a registry key to the specified location of the local or remote computer
Syntax:reg copy KeyName1 KeyName2 [/s] [/f]
parameter
KeyName1
Specifies the full path to copy the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU and HKCC. If you specify a remote computer, only HKLM and HKU subdirectory trees can be used.
KeyName2
Specifies the full path to the subproject's land. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU and HKCC. If you specify a remote computer, only HKLM and HKU subdirectory trees can be used.
/s
Copy all children and items under the specified child.
/f
Copy the child directly without requesting confirmation.
/?
Show help in the command prompt.

Comments
This version of Reg does not require confirmation when copying children.
The following table lists the return values ​​of the reg copy operation. Value description
0 Success
1 Failed

example
The following example shows how to use the reg copy command:
reg copy "hkcu\software\microsoft\winmine" "hkcu\software\microsoft\winminebk" /s /f
reg copy "hkcu\software\microsoft\winminebk" "hkcu\software\microsoft\winmine" /s

5. reg export Creates a copy of the specified child items, items and values ​​into a file to transfer them to other servers
Syntax:reg export KeyName FileName
parameter
KeyName
Specifies the full path to the child. The Export operation works only on the local computer. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU and HKCC.
FileName
Specifies the name and path to export the file. The file must have a .reg extension.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg export operation. Value description
0 Success
1 Failed

example
The following example shows how to use the reg export command:
reg export "hkcu\software\microsoft\winmine" c:\data\regbackups\

6. reg import Copy files containing the exported registry subkeys, entries and values ​​into the registry of the local computer
Syntax:reg import FileName
parameter
FileName
Specifies the name and path of the file to be copied to the local computer registry. The file must be created with the reg export command in advance.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg import operation. Value description
0 Success
1 Failed

example
The following example shows how to use the reg import command:
reg import hkcu\software\microsoft\winmine" c:\data\regbackups\

7. reg load writes saved children and entries back to different children in the registry
The purpose is to save it to a temporary file that can be used for troubleshooting registry keys or editing registry keys.
Syntax:reg load KeyName FileName
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory tree is HKLM

 8. reg query returns the list of items under the child key of the registry and the next level of the child key
Syntax:reg query KeyName [{/v EntryName|/ve}] [/s]
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only the HKLM and HKU subdirectory trees are available.
/v EntryName
Returns a specific item and its value. This parameter returns only items that are directly located in the next layer of the specified child. The item in the child under the current child will not be found. If EntryName is omitted, all items under the child will be returned.
/ve
Specifies only items that return null values.
/s
All children and items in each layer will be returned. If this parameter is not used, only the child and item of the next layer will be returned.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg query operation. Value Description
0 Success
1 Failed

example
The following example shows how to use the reg query command:
reg query "hklm\system\currentcontrolset\control\session manager" /v maxstacktracedepth
reg query "hkcu\software\microsoft\winmine" /s

9. reg restore writes saved children and items back to the registry
Syntax:reg restore KeyName FileName
parameter
KeyName
Specifies the full path to the child. The Restore operation works only on the local computer. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file that will be written back to the registry. The file must be pre-created using the reg save operation with the .hiv extension.
/?
Show help in the command prompt.

Comments
This action is used to overwrite the edited registry key. Before editing a registry key, use the reg save operation to save the parent child key. If editing fails, you can use this operation to restore the child.
The following table lists the return values ​​for the reg restore operation. Value Description
0 Success
1 Failed

example
The following example shows how to use the reg restore command:
reg restore "hkcu\software\microsoft\winmine"

 10. reg save saves a copy of the specified child key, key and registry value to the specified file.
grammar
reg save KeyName FileName
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the created file. If no path is specified, the current path is used.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg save operation. Value Description
0 Success
1 Failed

example
The following example shows how to use the reg save command:
reg save "hkcu\software\microsoft\winmine"

11. reg unload Use the reg load operation to delete some of the loaded registries
Syntax:reg unload KeyName
parameter
KeyName
Specifies the full path to the child. For remote computers, include the computer name before the child path in \\ComputerName\PathToSubkey. Ignoring ComputerName causes operations on the local computer by default. Start the path with the corresponding subdirectory tree. The valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
/?
Show help in the command prompt.

Comments
The following table lists the return values ​​for the reg unload operation. Value Description
0 Success
1 Failed

example
The following example shows how to use the reg unload command:
reg unload "hkcu\software\microsoft\winminebk2"