CMD to delete, add, modify registry commands

Source: Internet
Author: User

Transferred from: http://www.jb51.net/article/30586.htm

operation 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 the registry from.
/e filename3 Specifies the file to the export of the registry to.
REGPATH specifies the starting registry key to export from.
(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 through the registry almost anything can be done, the real question is how to quickly find the right registration key.

In most cases, manipulating the registry means finding a specific subkey, and occasionally, you may need to modify the name of the key all at once (for example, you might want to make structural changes). So how can you quickly find the right subkey and perform the modification? Also, if you want to change not only the registry of the local machine, but
The remote machine makes the same changes,
What should I do? This article tells you a good tool to regfind. Regfind can be found from the Windows Resource Kit Supplement one, or downloaded from the Web. Regfind is available for each version of Windows, including the Windows 9x series.

Regfind is a command-line tool. Executes regfind without any options, it will display help information. The simplest usage is to perform a lookup, such as executing regfind "QQ", Regfind will find all the registered keys that contain the string "QQ", as shown in.

In addition to simple lookups, Regfind is able to perform replacements: simply add the-r option and a replacement string after the Tuyi command. For example, if your company's name changed from Agroup to Bgroup, now you want to change all of the product registration information in the registry, just do: 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 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 to the remote machine, for example: Regfind-m\\server03 "Agroup" -R "Bgroup".

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

As you can see from the instructions above, regfind is a handy tool, but Babbitt has flaws, and sometimes you still feel that it can't meet the requirements. First, Regfind does not support wildcard characters, and regular expressions are not supported--both of which are useful for performing complex searches. The only option to add flexibility to a search operation is-y. The-y option makes Regfind's search operation insensitive to case, that is, if you perform regfind agroup-y, Regfind's search results will contain agroup, Agroup, and other alphabetic case combinations (if you do not have the-y option, Regfind is case-sensitive by default, but Regfind's command options are not case sensitive, for example, you can use-R or-R at will.

Second, if you perform a search/replace operation with Regfind, it will replace all the found strings, and you cannot require regfind to replace only one of the strings. The only way to be a remediation strategy is to limit the search operation to a specific registry branch. Therefore, my advice is: First use regfind to find all matching registered subkeys, and then use Regfind to perform a global substitution or manually modify a specific sub-key.

Third, if you want to modify numeric data, Regfind doesn't seem like the best helper. This is because many of the REG_DWORD values to be processed are either 0 or 1, while the chances of 0 and 1 appearing in the registry are too frequent and are likely to be replaced by mistake. The only way to solve the problem is to limit Regfind's search scope as precisely as possible

Direct modification of the registry by the command-line method

First, CMD
CMD is a windows2000 in a small like pigeon Egg program, is a so-called command line console. There are two channels to enter the program: first, the mouse click "Start-> Run", type "cmd" in the edit box that appears, and then click "OK"; second, when you start Windows2000, press F8 to enter the boot selection menu, move the light bar, or type a number into the command line state of Safe mode. The window that appears is a msdos-like interface that is common in Win9x systems-a dark window. There is even no msdos window engaging: Even the usual toolbars are not put on. I really do not know, expensive for the latest operating system, why still retain seems to be the Stone Age DOS interface? As usual, habitually low after the command type: cmd/? , want to see what will be prompted?
I was surprised by what appeared: 1. This information is Chinese, to know that the original pure DOS environment can not directly support Chinese Ah! 2. There is quite detailed help information. 3. Although the interface is command line, it can be used for many deep-seated projects, such as modifying the registry and so on. Later use also proves that CMD can actually invoke the graphical interface program directly, and can return to the command line interface after the call is finished.
Although Microsoft uses this tool as a new instance of the command interpreter, but the method used is no different from the original DOS, after opening 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 this 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 executes the command specified by the string and then finally breaks
/k executes the command specified by the string but retains
/S Modify string processing after/C or/k (see below)
/q Close Response
/d deactivates the Execute AutoRun command from the registry (see below)
/A makes the output to an internal pipe or file command ANSI
/u makes the output to an internal pipe or file command Unicode
/T:FG setting the 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 the C as a delimiter to postpone the environment variable extension. such as:/v:on will
Allow!var! Allow!var! at execution time Extended variable var. var syntax
Expands the variable at input, which is different from a for loop.
/v:off deactivate the deferred environment extension.

Note that if the string is quoted, 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/C or/K is specified, the remainder of the command line after the command option is processed as a command line, in which case the quotation mark character (") is processed using the following logic:

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

-No/S command options
-Full two quote characters
-There are no special characters between the two quotation marks characters, and the special characters are the following
One: <> () @^|
-there is at least one white-space character between two quote characters
-there is at least one executable file name between the two quotation marks characters.

2. Otherwise, the old-fashioned way is to see if the first character is a quotation mark character, and if it is, remove the beginning character and delete the last quote character on the command line, preserving 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 at the default value. You can also use/e:off to deactivate an extension for a specific call. You can enable or disable CMD on the machine and/or on the user logon session. EXE all calls are extended by setting one or two REG_DWORD values in the registry using 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 has so-called internal commands and external commands, in CMD, the introduction of the command line extension, you can directly execute the following extension in the cmd window, the expansion of the section without the need to add cmd.
The command-line extension includes 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
Pager
SHIFT
Goto
START (including changes made to external command calls)
ASSOC
FTYPE

For more information, type the help command name.

Second, REG
You can do this by windowsxp the provided reg command line.
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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC.
/V EntryName
Specifies the name of the item to add to the specified subkey.
/ve
Specifies that entries added to the registry are null values.
/T DataType
Specifies the data type of the item value. The DataType can be of several 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 you need to list multiple items. If not specified, the default delimiter for \ is used.
/d Value
Specifies the value of the new registry key.
/F
Add a subkey or item directly without asking for information.
/?
Displays help at the command prompt.
Comments
The operation cannot add subtrees. This version of Reg does not require a request for confirmation when adding subkeys.
The following table lists the return values for the REG add operation. Value Description
0 successes
1 failure

Example
The following example shows 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 item.

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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only the HKLM and HKU subtree can be used.
/V EntryName
Compares a specific item under a subkey.
/ve
Specifies that only items that have no value can be compared.
{[/oa]| [/od]| [/os]| [On]}
Specifies how different points and match points are displayed. The default setting is/od. Value Description
/OA specifies that all different points and matching points are displayed. By default, only 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 different points are listed.
/ON Specifies that no content is displayed. By default, only different points are listed.

/s Separator
Compares all subkeys and items.
/?
Displays 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 Compare successes and find 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 a local or remote computer at the specified location.

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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only the HKLM and HKU subtree can be used.
KeyName2
Specifies the full path of the sub-project's location. For a remote computer, include the computer name in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only the HKLM and HKU subtree can be used.
/s
Copies all subkeys and items under the specified subkey.
/F
Copy the subkey directly without requesting confirmation.
/?
Displays help at the command prompt.
Comments
This version of Reg does not require confirmation when copying subkeys.
The following table lists the return values for the reg copy operation. Value Description
0 successes
1 failure

Example
The following example illustrates 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

To 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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is 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 are nullable can be deleted.
/va
Deletes all items under the specified subkey. You cannot delete a subkey under a specified subkey by using this parameter.
/F
Delete an existing registry subkey or item without requesting confirmation.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the reg delete operation. Value Description
0 successes
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 a different 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 in the appropriate subtree. Valid subtree is 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.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the Reg export operation. Value Description
0 successes
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 files that contain 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 using the reg EXPORT command.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the reg import operation. Value Description
0 successes
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 entries back to different subkeys in the registry. The purpose is to save to a temporary file, and the file can be used to troubleshoot registry keys 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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file to be loaded. The file must be created using the Reg save operation with the. HIV extension.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the reg load operation. Value Description
0 successes
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 under the subkey of the registry and the next level of subkeys.

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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC. If you specify a remote computer, only the HKLM and HKU subtree can be used.
/V EntryName
Returns a specific item and its value. This parameter returns only the items that are directly in the next level 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 that only items returned as null values.
/s
All subkeys and items in each layer are returned. If you do not use this parameter, only the next level of subkeys and items will be returned.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the REG query operation. Value Description
0 successes
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 entries 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 in the appropriate subtree. Valid subtree is 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 pre-create the file.
/?
Displays help at the command prompt.
Comments
This action is used to overwrite an 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 restore the subkey.
The following table lists the return values for the Reg restore operation. Value Description
0 successes
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 in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC.
FileName
Specifies the name and path of the file that is created. If no path is specified, the current path is used.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the Reg save operation. Value Description
0 successes
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 portion of the registry that has already been loaded.

Grammar
Reg Unload KeyName

Parameters
KeyName
Specifies the full path of the subkey. For a remote computer, include the computer name in front of the subkey path. Ignoring ComputerName causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC.
/?
Displays help at the command prompt.
Comments
The following table lists the return values for the reg unload operation. Value Description
0 successes
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 may severely damage your system. Before you make changes to 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, compromise the system, and even require users to reinstall Windows. You can use Program security in Control Panel or Microsoft management Console (MMC) to change most registry settings. If you must edit the registry directly, back it up first. For more information, see "Registry Editor Help".
Comments
Use Reg to edit the registry of a local or remote computer directly. These changes may cause the computer to be unable to operate and require the operating system to be reinstalled. So instead of editing the registry directly, you should change the registry as much as possible by using Control Panel or Microsoft management Console (MMC).
Some operations can view or configure registry entries for local or remote computers, while others allow you to configure registry settings for the local computer only. Also, remote access to the registry may limit the parameters that are used for an operation. Check the syntax of each operation to verify that the operation can be used on the remote computer, and to verify the parameters that can be used in that case.

allow Windows registry modifications to take effect quickly

When we modify the registry, in many cases only pressing the F5 key to refresh the registry is not sufficient for the modification to take effect, but requires a restart of the computer. In fact, we don't have to restart the machine every time, just run the Shell Explorer of Windows (the operations in Windows 9x/me and Windows 2000/xp are different).

In Windows 9x/me

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

In Windows 2000/XP

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

CMD to delete, add, modify registry commands

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.