Reg command is necessary to use detailed batch operation registry

Time:2020-3-26

Edit the registry directly only when there is no other choice. The registry editor ignores standard security measures, which can degrade performance, damage the system, and even require users to reinstall windows. Most registry settings can be changed using program security in the control panel or Microsoft Management Console (MMC). If you must edit the registry directly, back it up first. Use Reg to directly edit the registry of a local or remote computer. These changes may cause the computer to become inoperable and require the operating system to be reinstalled. So instead of editing the registry directly, use the control panel or the Microsoft Management Console (MMC) as much as possible to change the registry. Some operations can view or configure registry keys for local or remote computers, while others only allow configuration of registry settings for local computers. At the same time, remote access to the registry may restrict the parameters used for an operation. Check the syntax of each operation to verify that the operation can be used on a remote computer, and to verify the parameters that can be used in that case.

 The reg command is provided by Windows XP to add, change, and display registry subkey information and values in registry keys.

1. Reg add adds a new subkey or key to the registry
Syntax: reg add keyname [/ V entryname| / ve] [/ T datatype] [/ s separator] [/ D value] [/ F]
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC. There are only HKLM and HKU on the remote machine.
Value description
  HKCR: HKEY_CLASSES_ROOT
  HKCU: HKEY_CURRENT_USER
  HKLM: HKEY_LOCAL_MACHINE
  HKU: HKEY_USERS
  HKCC: HKEY_CURRENT_CONFIG

  /v EntryName
Specifies the name of the item to add to the specified child.
  /ve
Specifies that the key added to the registry is null.
  /t DataType
Specifies the data type of the item value. Datatypes can be of the following types:
  REG_SZ
  REG_MULTI_SZ
  REG_DWORD_BIG_ENDIAN
  REG_DWORD
  REG_BINARY
  REG_DWORD_LITTLE_ENDIAN
  REG_LINK
  REG_FULL_RESOURCE_DESCRIPTOR
  REG_EXPAND_SZ

  /s separator
Specifies the characters used to separate multiple data instances. Use this parameter when reg? Multi? SZ is specified as a data type and more than one item needs to be listed. If not specified, the default separator will be “\ 0”.
  /d value
Specifies the value of the new registry key.
  /f
Add children or items without asking for information.
  /?
Display help at the command prompt.

Notes
The operation cannot add a subtree. This version of reg does not require confirmation when adding children.
The following table lists the return values for the reg add operation. Value specification
0 succeeded
1 failed

/V the name of the value to be added under the selected item.

/Ve adds a blank value name for the registry key (default).

/T regKey data type
[ REG_SZ | REG_MULTI_SZ | REG_EXPAND_SZ |
REG_DWORD | REG_QWORD | REG_BINARY | REG_NONE ]
If omitted, reg ﹣ SZ is used.

/S specifies a character to be used as a separator in the reg? Multi? SZ data string
“\ 0” is used as the separator if ignored.

/D data to be assigned to the added registry valuename.

/F force an existing registry key to be overwritten without prompting.

Example
(supplement: CMD / K is to use the reg command in operation)
The following example shows how to use the reg add command:
CMD / K reg add “HKLM \ software \ Microsoft \ windows \ CurrentVersion \ Explorer \ advanced \ folder \ hidden \ showall” / V checkdvalue / T reg \ DWORD / D 1 / F (show hidden files and folders)
CMD / K reg add “HKLM \ software \ Microsoft \ windows \ CurrentVersion \ run” / V system / T reg? SZ / D “% systemroot% \ system32 \ system. Exe” / F
CMD / K reg add “HKLM \ software \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon” / V shell / T reg_sz / D “% systemroot% \ explorer. Exe” / F
CMD / K reg add “HKLM \ software \ Microsoft \ windows \ CurrentVersion \ run” / V soundman / T reg? SZ / D “% systemroot% \ soundman. Exe” / F
  cmd /k reg add “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE” /ve /d “%ProgramFiles%\Internet Explorer\IEXPLORE.EXE” /t REG_SZ /f
(UC room can’t open broadcasting)
  cmd /k reg add “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSCONFIG.EXE” /ve /d “%SystemRoot%\PCHealth\HelpCtr\Binaries\MSConfig.exe” /t REG_SZ /f
(running msconfig prompts that the file cannot be found)
  cmd /k reg add “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wmplayer.exe” /ve /d “%ProgramFiles%\Windows Media Player\wmplayer.exe” /t REG_SZ /f
(unable to call WMP player repair normally)
  cmd /k reg add “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WORDPAD.EXE” /ve /d “%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE” /t REG_SZ /f
(unable to call the repair of WordPad normally)
CMD / K reg add “HKCU \ software \ Microsoft \ windows \ CurrentVersion \ run” / V ctfmon.exe / T reg? SZ / D “% systemroot% \ system32 \ Ctfmon. Exe” / F (boot input method program Ctfmon)
CMD / K reg add “HKCU \ controlpanel \ desktop” / V waittokillapptimeout / T reg_sz / D 10000 / F

For example:

REG ADD \\ABC\HKLM\Software\MyCo
Add a registry key HKLM \ software \ Myco on the remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Add a value (Name: data, type: reg? Binary, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
Add a value (Name: MRU, type: reg? Mutli? SZ, data: fax \ 0mail \ 0 \ 0)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%
Add a value (Name: path, type: reg? Expand? SZ, data:% systemroot%)
Note: use caret (^) in extended string

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 deletes a key or subkey from the registry
Syntax: reg delete keyname [{/ V entryname| / ve| / VA}]]] / F]
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC.
  /v EntryName
Delete specific items under children. If no item is specified, all items and children under the child are deleted.
  /ve
Specifies that only items with null values can be deleted.
  /va
Deletes all items under the specified child. This parameter cannot be used to delete a subkey under the specified subkey.
  /f
Delete an existing registry subkey or key without requesting confirmation.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg delete operation. Value specification
0 succeeded
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 \ taskmgr. Exe” / F (Task Manager in the taskbar is gray)
CMD / K reg delete “HKLM \ software \ Microsoft \ shared tools \ msconfig \ startupreg” / F
CMD / K reg delete “HKLM \ software \ Microsoft \ Windows NT \ CurrentVersion \ image file execution options \ Ctfmon. Exe” / F
  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

 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 of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only HKLM and HKU subtrees can be used.
  /v EntryName
Compare specific items under children.
  /ve
Specifies that only items without values can be compared.
  {[/oa]|[/od]|[/os]|[on]}
Specifies how different points and match points are displayed. The default setting is / OD. Value specification
/ OA specifies that all different points and match points are displayed. By default, only different points are listed.
/ OD specifies that only different points are displayed. This is the default operation.
/ OS specifies that only match points are displayed. By default, only different points are listed.
/ on specifies that nothing is displayed. By default, only different points are listed.
  /s Separator
Compare all children and items.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg compare operation. Value specification
0 was successful and the results were the same.
1 Comparison failed.
2 compare success and find differences.

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 copies a registry key to a specified location on a local or remote computer
Syntax: reg copy keyname1 keyname2 [/ S] [/ F]
Parameter
  KeyName1
Specifies the full path to copy children. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only HKLM and HKU subtrees can be used.
  KeyName2
Specifies the full path to the location of the subproject. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only HKLM and HKU subtrees can be used.
  /s
Copies all children and items under the specified children.
  /f
You do not need to request confirmation to copy children directly.
  /?
Display help at the command prompt.

Notes
This version of reg does not require confirmation when copying children.
The following table lists the return values for the reg copy operation. Value specification
0 succeeded
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 children, items, and values into a file for transfer to another server
Syntax: reg export keyname filename
Parameter
  KeyName
Specifies the full path of the child. The export operation can only work on the local machine. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC.
  FileName
Specify the name and path of the file to export. The file must have a. Reg extension.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg export operation. Value specification
0 succeeded
1 failed

Example
The following example shows how to use the reg export command:
  reg export “hkcu\software\microsoft\winmine” c:\data\regbackups\wmbkup.reg

  6, reg import copies files containing exported registry subkeys, keys, and values to the registry of the local computer
Syntax: reg import filename
Parameter
  FileName
Specifies the name and path of the file that will be copied to the local computer registry. The file must be created using the reg export command in advance.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg import operation. Value specification
0 succeeded
1 failed

Example
The following example shows how to use the reg Import command:
  reg import hkcu\software\microsoft\winmine” c:\data\regbackups\wmbkup.reg

  7. Reg load writes saved subkeys and keys back to different subkeys in the registry
The purpose is to save to a temporary file that can be used to troubleshoot or edit registry keys.
Syntax: reg load keyname filename
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid subtree is HKLM

 8. Reg query returns the list of keys and next level subkeys under the subkeys of the registry
Syntax: reg query keyname [{/ V entryname| / ve}]] / S]
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only HKLM and HKU subtrees can be used.
  /v EntryName
Returns a specific item and its value. This parameter returns only items that are directly in the next level of the specified child. Items in children under the current child will not be found. If you omit entryname, all items under the child are returned.
  /ve
Specifies that only items that return null values are returned.
  /s
All children and items in each layer are returned. If you do not use this parameter, only the children and items of the next level will be returned.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg query operation. Value specification
0 succeeded
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 subkeys and keys back to the registry
Syntax: reg restore keyname filename
Parameter
  KeyName
Specifies the full path of the child. The restore operation works only on the local machine. Start the path with the corresponding subdirectory tree. Valid sub 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.
  /?
Display help at the command prompt.

Notes
This operation is used to overwrite the edited registry key. Before editing a registry key, use the reg save operation to save the parent subkey. If the edit fails, you can use this operation to recover the children.
The following table lists the return values for the reg restore operation. Value specification
0 succeeded
1 failed

Example
The following example shows how to use the reg restore command:
  reg restore “hkcu\software\microsoft\winmine” wmbkup.hiv

 10, reg save saves a copy of the specified subkeys, keys, and registry values to the specified file.
Syntax
  reg save KeyName FileName
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC.
  FileName
Specifies the name and path of the file created. If no path is specified, the current path is used.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg save operation. Value specification
0 succeeded
1 failed

Example
The following example shows how to use the reg Save command:
  reg save “hkcu\software\microsoft\winmine” wmbkup.hiv

  11. Reg unload use the reg load operation to delete part of the loaded registry
Syntax: reg unload keyname
Parameter
  KeyName
Specifies the full path of the child. For remote computers, include the computer name before the subkey path in \ \ computername \ pathtosubkey. Ignoring computername causes the local computer to operate by default. Start the path with the corresponding subdirectory tree. Valid sub trees are HKLM, HKCU, HKCR, HKU, and HKCC.
  /?
Display help at the command prompt.

Notes
The following table lists the return values for the reg unload operation. Value specification
0 succeeded
1 failed

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