Remove, add, and modify registry commands in DOS (CMD) _dos/bat

Source: Internet
Author: User
Tags naming convention
Operating parameters of Regedit

REGEDIT [/l:system] [/r:user] filename1
REGEDIT [/l:system] [/r:user]/C filename2
REGEDIT [/l:system] [/r:user]/e filename3 [Regpath]
/L:SYSTEM Specifies the location of the system. DAT file.
/R:USER Specifies the location of the user. DAT file.
FILENAME1 Specifies the file (s) to import into the regist
/C filename2 Specifies the "file to create" registry from.
/e filename3 Specifies the "file to export" registry to.
REGPATH specifies the starting registry key to export.
(Defaults to exporting the entire registry).
/S (Windows) silent-no message on completion.

To quickly manipulate the registry from the Windows command line

Everyone familiar with Windows believes that almost anything can be done through the registry, and the real question is how to quickly find the right registration key.

In most cases, manipulating the registry means finding a specific subkey; Occasionally, you may need to modify the name of a key (for example, a structural change might be required). So, how can you quickly find the right subkey and perform the modification? In addition, if you want to change not only the local machine's registry, but also the
The remote machine makes the same modifications,
What should I do? This article tells you a good tool regfind. Regfind can be found from Windows Server's resource Kit supplement one, or downloaded from the Web. Regfind applies to various versions of Windows, including the Windows 9x family.

Regfind is a command line tool. Executes regfind with no options, and it displays help information. The simplest use is to perform a lookup, such as executing regfind "QQ", and Regfind will find all the registration keys that contain the string "QQ", as shown in figure one.

In addition to simple lookups, regfind can also perform replacements: simply add the-r option and a replacement string after the Tuyi command. For example, suppose your company's name changed from Agroup to Bgroup, and now you want to make the appropriate changes to all the registration information in the registry, just perform the following: Regfind "Agroup"-R "Bgroup". Note that if the search string contains spaces or punctuation, the string should be enclosed in quotation marks.

If you want to make a corresponding change to a remote machine, simply add the-m option to the previous command and specify the UNC (universal naming convention, Universal Naming convention) path for the remote machine, for example: Regfind-m\\server03 "Agroup" -R "Bgroup".

Searching the entire registry is definitely a time-consuming task. To improve efficiency, you can limit the regfind search operation to a branch or subkey of a registry, simply by specifying the registry location to search for after the-p option. For example, suppose you want to restrict the operation of the search "Agroup" to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft subkey and replace the Agroup under that subkey with Bgroup, execute: regfind "Agroup"-R " Bgroup "-P" hkey_local_machinesoftware\microsoft ".

It can be seen from the above instructions, Regfind is a very convenient tool, but Babbitt have flaws, sometimes you will still feel that it can not meet the requirements. First, Regfind does not support wildcard characters or regular expressions--both of which are useful for performing complex searches. The only option that adds flexibility to the search operation is-y. The-y option makes regfind search operations insensitive to case, that is, if you perform regfind agroup-y, Regfind's search results will contain a combination of agroup, agroup, and other letter-case combinations (if you do not have the-y option, Regfind is case sensitive by default, but regfind command options are not case sensitive, for example, you can use the-R or-R at your discretion.

Second, if you perform a search/replace operation with Regfind, it replaces all the found strings, and you cannot ask Regfind to replace only one of the strings. The only way to remedy the strategy is to limit the search operation to a specific registry branch. So my advice is to first use regfind to find all the matching registry subkeys and then use Regfind to perform global substitution or manually modify a particular subkey.

Third, if you want to modify the numeric data, Regfind doesn't seem to be the best helper. This is because many of the REG_DWORD values to be processed are either 0 or 1, and 0 and 1 have the opportunity to appear in the registry too frequently, and there is a good chance of a false substitution. The only way to solve the problem is to limit the regfind search scope as precisely as possible

Modify the registry directly from the command line

First, CMD
CMD is a small windows2000 like pigeon eggs in the same program, is a so-called command line console. There are two channels into the program: first, click on the mouse "Start-> Run", in the appearance of the edit box type "cmd", and then click "OK"; second, when starting Windows2000, press F8 to enter the boot selection menu, move the light bar or type the number into Safe mode of the command line state. The window that appears is a MSDOS interface that is common in Win9x systems-a dark window. There is not even a msdos way of window engaging: Even the most commonly used tool bars are not placed on. I really can't figure out that you are the newest operating system, and why do you still retain what seems to be the Stone Age of the DOS interface? As usual, habitually low after the command type: cmd/? , want to see what will be prompted?
I was surprised by what had arisen: 1. This information is in Chinese, to know that the original pure DOS environment can not directly support the Chinese Ah! 2. There are quite detailed information about the help. 3. Although the interface is a command line, it can operate on many deep projects, such as modifying the registry and so on. Later use also proved that CMD can actually directly call the graphical interface of the program, and at the end of the call can return to the command line interface.
Although Microsoft uses this tool as a new instance of the command interpreter, the method used is not the same as the original DOS, when you open the Command Line window, you can find the same system prompt symbol C:/&gt as DOS, and the command must be typed at the back of the prompt to confirm with the ENTER key.
The complete syntax is as follows:
CMD [A/u] [/q] [d] [/e:on |/e:off] [/f:on |/f:off] [/v:on |/v:off]
[[/S] [/C |/k] string]
The meaning of each parameter:
CMD: Is the command name, which can be omitted. The following are the parameters or switches used by the command.
/C Execute the command specified by the string and then break
/k executes the command specified by the string but retains
/S Modify string processing after/C or/k (see below)
/q Close Response
/d Deactivate the Execute AutoRun command from the registry (see below)
/A to make the output of an internal pipe or file command ANSI
/U make output to internal pipe or file command Unicode
/T:FG set foreground/Background color (For more information, see Color/?)
/e:on enable command Extensions (see below)
/e:off Disable Command Extensions (see below)
/f:on enable file and directory name completion characters (see below)
/f:off disable file and directory name completion characters (see below)
/v:on starts the C as a delimiter to delay the environment variable extension. such as:/v:on will
Allow!var! Allow!var! at execution time Extended variable var. var syntax
Expands the variable as it is entered, which is different from within a for loop.
/v:off deactivate a deferred environment extension.

Note that if the string has quotes, it can be separated by the command delimiter ' && '
Multiple commands. And, for compatibility reasons,/x is the same as/e:on,/y and
/e:off is the same, and/R is the same as/C. Ignore any other command options.

If you specify/C or/K, the rest of the command line after the command option is processed as a command line, in which case the following logical processing quotation mark character (") is used:

1. If all of the following conditions are true, the quote character on the command line will be
Keep:

-Not with/S command option
-Full two quote characters
-There are no special characters between the two quote characters, and the special characters are the following
One: <> () @^|
-At least one white-space character between two quote characters
-The name of at least one executable file between two quote characters.

2. Otherwise, the old way is to see whether the first character is a quote character, if it is, give up the character at the beginning and delete the last quote character on the command line, leaving the text after the last quotation mark character. If/d is not specified on the command line, when CMD. EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variable. If one or two of them are present, the two variables are executed first.
Hkey_local_machinesoftwaremicrosoftcommand Processorautorun
and/or
Hkey_current_usersoftwaremicrosoftcommand Processorautorun
Command extensions are enabled by default values. You can also use/e:off to deactivate an extension for a particular call. You can enable or disable CMD on the machine and/or at the user logon session. EXE for all calls, this is done by setting one or two REG_DWORD values in the registry using the REGEDT32.EXE:
Hkey_local_machinesoftwaremicrosoftcommand processorenableextensions
and/or
Hkey_current_usersoftwaremicrosoftcommand processorenableextensions
To 0x1 or 0x0. User-specific settings have precedence over machine settings. Command-line command options have precedence over registry settings.
The original DOS in the so-called internal commands and external commands, in the CMD, the introduction of the command line extension, you can in the CMD window directly to execute the expansion of the following section, the extension of the part without CMD.
Command line extensions include changes and/or additions to the following commands:
DEL or ERASE
COLOR
CD or CHDIR
MD or MKDIR
PROMPT
PUSHD
POPD
SET
SETLOCAL
Endlocal
IF
For
Call
SHIFT
Goto
START (also includes changes made to external command calls)
ASSOC
FTYPE

For more information, type the help command name.

Second, REG
Can be done with the Reg command line provided by Windows XP.
Reg adds, changes, and displays registry subkey information and values in the registry key.

To view the command syntax, click the following command:

REG ADD

Adds a new subkey or item to the registry.

Grammar
REG ADD KeyName [/V entryname|/ve] [/t DataType] [/s separator] [/D value] [F]

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
/V EntryName
Specifies the name of the item to add to the specified subkey.
/ve
Specifies that the entries added to the registry are null values.
/T DataType
The data type of the specified item value. DataType 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 character used to separate multiple instances of data. Use this parameter when REG_MULTI_SZ is specified as a data type and you need to list more than one item. If not specified, the default delimiter is used for \.
/d Value
Specifies the value of the new registry key.
/F
Add subkeys or items directly without asking for information.
/?
Display Help at the command prompt.
Comments
This operation cannot add a subtree. This version of Reg does not need to request confirmation when adding subkeys.
The following table lists the return values for the REG add operation. Value Description
0 success
1 failure

Example
The following examples illustrate how to use the REG ADD command:

REG ADD \hklm\software\myco/v data/t reg_binary/d fe340ead
REG ADD "hkcu\software\microsoft\winmine"/V name3/t reg_sz/d Anonymous
REG ADD "hkcu\software\microsoft\winmine"/V time3/t reg_dword/d 5

Reg Compare

Compares the specified registry subkey or key.

Grammar
Reg Compare KeyName1 KeyName2 [/V entryname |/ve] {[/oa]|[ /od]| [/os]| [On]} [/s]

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, you can use only HKLM and HKU subtree.
/V EntryName
Compares a specific item under a subkey.
/ve
Specifies that only items with no value 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 the different points and matching points are displayed. By default, only the different points 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 different points are listed.
/ON Specifies that no content is displayed. By default, only the different points are listed.

/s Separator
Compares all subkeys and items.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the Reg compare operation. Value Description
0 is more successful and the results are the same.
1 comparison failed.
2 more successful and found different points.

Example
The following example shows how to use the Reg compare command:

Reg compare "hkcu\software\microsoft\winmine" "hkcu\software\microsoft\winmine"/od/s

Reg copy

Copies a registry key to the specified location on the local or remote computer.

Grammar
Reg copy KeyName1 KeyName2 [/s] [/f]

Parameters
KeyName1
Specifies the full path of the subkey to be copied. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, you can use only HKLM and HKU subtree.
KeyName2
Specifies the full path of the child project's land. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, you can use only HKLM and HKU subtree.
/s
Copies all subkeys and items under the specified subkey.
/F
The subkey is copied directly without requesting confirmation.
/?
Display Help at the command prompt.
Comments
This version of Reg does not need to request confirmation when copying subkeys.
The following table lists the return values for the reg copy operation. Value Description
0 success
1 failure

Example
The following examples illustrate 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

Reg delete

Delete an item or subkey from the registry

Grammar
reg DELETE KeyName [{/V Entryname|/ve|/va}] [F]

Parameters
KeyName

Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
/V EntryName
Deletes a specific item under a subkey. If no item is specified, all items and subkeys under the subkey are deleted.
/ve
Specifies that only items that can be deleted are null values.
/va
Deletes all items under the specified subkey. You cannot delete a subkey under a specified subkey using this parameter.
/F
Deletes an existing registry subkey or item without requesting confirmation.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the reg delete operation. Value Description
0 success
1 failure

Example
The following example shows how to use the reg delete command:

reg delete "hkcu\software\microsoft\winmine"/V Name1
reg delete "hkcu\software\microsoft\winmine"/V Time1
reg delete "hkcu\software\microsoft\winmine"/va

Reg Export

Creates a copy of the specified subkey, item, and value into a file so that it can be transferred to another server.

Grammar
Reg EXPORT KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey. The Export operation can only work on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file to be exported. The file must have a. reg extension.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the Reg export operation. Value Description
0 success
1 failure

Example
The following example shows how to use the Reg Export command:

Reg export "hkcu\software\microsoft\winmine" C:\data\regbackups\wmbkup.reg

Reg Import

Copy the file that contains the exported registry subkeys, keys, and values to the local computer's registry.

Grammar
Reg Import FileName

Parameters
FileName
Specifies the name and path of the file that will be copied to the local computer registry. The file must be created in advance by using the REG Export command.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the reg import operation. Value Description
0 success
1 failure

Example
The following example shows how to use the Reg import command:

Reg Import Hkcu\software\microsoft\winmine "C:\data\regbackups\wmbkup.reg

Reg load

Writes the saved subkeys and items back to the different subkeys of the registry. The purpose is to save to a temporary file that can be used to troubleshoot or edit registry keys.

Grammar
Reg LOAD KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file to load. The file must be created using the Reg save operation with the. HIV extension.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the reg load operation. Value Description
0 success
1 failure

Example
The following example shows how to use the reg load command:

Reg load "HKCU\SOFTWARE\MICROSOFT\WINMINEBK2" Wmbkup.hiv

Reg Query

Returns a list of items and next-level subkeys under subkeys of the registry.

Grammar
Reg QUERY KeyName [{/V entryname|/ve}] [/s]

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, you can use only HKLM and HKU subtree.
/V EntryName
Returns a specific item and its value. This parameter returns only the items that are directly in the next layer of the specified subkey. The item in the subkey under the current subkey will not be found. If EntryName is omitted, all items under the subkey are returned.
/ve
Specifies an item that is returned only as a null value.
/s
All the subkeys and items in each layer are returned. If you do not use this argument, only the next level of subkeys and items will be returned.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the REG query operation. Value Description
0 success
1 failure

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

Reg restore

Writes the saved subkeys and items back to the registry.

Grammar
Reg RESTORE KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey. The Restore operation works only on the local computer. Start the path with the appropriate subdirectory tree. 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. You must use the Reg save operation with the. HIV extension to create the file beforehand.
/?
Display Help at the command prompt.
Comments
This action overrides the edited registry key. Before you edit the registry key, use the Reg save action to save the parent child. If the edit fails, you can use this action to recover the subkey.
The following table lists the return values for the Reg restore operation. Value Description
0 success
1 failure

Example
The following example shows how to use the reg RESTORE command:

Reg restore "hkcu\software\microsoft\winmine" Wmbkup.hiv

Reg Save

Saves a copy of the specified subkey, item, and registry value to the specified file.

Grammar
Reg SAVE KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file you are creating. If no path is specified, the current path is used.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the Reg save operation. Value Description
0 success
1 failure

Example
The following example shows how to use the Reg Save command:

Reg save "hkcu\software\microsoft\winmine" Wmbkup.hiv

Reg unload

Use the reg load operation to delete a partially loaded registry.

Grammar
Reg UNLOAD KeyName

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in. Ignoring ComputerName causes the default to operate on the local computer. Start the path with the appropriate subdirectory tree. Valid subdirectory trees are HKLM, HKCU, HKCR, HKU, and HKCC.
/?
Display Help at the command prompt.
Comments
The following table lists the return values for the reg unload operation. Value Description
0 success
1 failure

Example
The following example shows how to use the reg unload command:

Reg unload "HKCU\SOFTWARE\MICROSOFT\WINMINEBK2"

Be careful

Improper editing of the registry can severely damage your system. Before you change the registry, you should back up any valuable data on your computer.
Be careful

Edit the registry directly only if you have no choice. Registry Editor ignores standard security measures so that these settings degrade performance, damage the system, and even require users to reinstall Windows. You can change most registry settings by using Program security in Control Panel or Microsoft management Console (MMC). If you must edit the registry directly, back it up first. For more information, see Registry Editor Help.
Comments
Edit the registry of the local or remote computer directly using REG. These changes may cause the computer to not operate and require the operating system to be reinstalled. So do not edit the registry directly, but make the registry change as much as possible by using Control Panel or Microsoft management Console (MMC).
Some operations can view or configure registry keys for local or remote computers, while others only allow you to configure registry settings for the local computer. Also, remote access to the registry may limit the parameters used for an operation. Check the syntax of each operation to verify that the operation is available to the remote computer, and to verify the parameters that can be used in that case.

Get Windows Registry modifications to take effect quickly

When we modify the registry, in many cases just pressing the F5 key to refresh the registry is not enough to make the changes take effect, and the computer needs to be restarted. In fact, we don't have to reboot the machine every time, just run Windows Shell Explorer (the operations in Windows 9x/me and Windows 2000/xp are different).

In Windows 9x/me

Press the "Ctrl+alt+delete" key combination, in the pop-up window select "Explorer", and click the "End Task" button, then the screen will appear "Shutdown" menu, do not do any action, in the pop-up window again click the "End Task" button, Lets Windows quickly refresh the registry without restarting.

In Windows 2000/XP

Press the "Ctrl+alt+delete" key combination, open Task Manager, click the Process tab, locate and click the "Explorer.exe" button, and click the "Yes" button in the Open Warning dialog box. Then click the Application tab, click the New Task button below, enter "Explorer.exe" in the Open Create New Task dialog box, and then press the OK button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.