Compartir a través de


Reg

Adds, changes, and displays registry subkey information and values in registry entries.

To view the command syntax, click a command:

reg add

Adds a new subkey or entry to the registry.

Syntax

reg add KeyName [/v EntryName|/ve] [/t DataType] [/s separator] [/d value] [/f]

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

/v   EntryName   : Specifies the name of the entry to be added under the specified subkey.

/ve   : Specifies that the entry that is added to the registry has a null value.

/t   DataType   : Specifies the data type for the value of the entry. DataType can be one of the following:

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. Used when REG_MULTI_SZ is specified as the data type and more than one entry needs to be listed. If not specified, the default separator is \0.

/d   value   : Specifies the value for the new registry entry.

/f   : Adds the subkey or entry without asking for confirmation.

/? : Displays help at the command prompt.

Remarks

  • Subtrees cannot be added with this operation. This version of Reg does not ask for confirmation when adding a subkey.

  • The following table lists the return values for the reg add operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following examples show how you can 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 specified registry subkeys or entries.

Syntax

reg compare KeyName1 KeyName2 [/v EntryName | /ve] {[/oa]|[/od]|[/os]|[on]} [/s

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathtoSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, you can use the HKLM and HKU subtrees only.

/v   EntryName   : Compares a specific entry under the subkey.

/ve   : Specifies that only entries that have no value will be compared.

{[ /oa ]|[ /od ]|[ /os ]|[ on ]} : Specifies how differences and matches are displayed. The default is /od.

Value

Description

/oa

Specifies that all differences and matches are displayed. By default, only the differences are listed.

/od

Specifies that only differences are displayed. This is the default behavior.

/os

Specifies that only matches are displayed. By default, only the differences will be listed.

/on

Specifies that nothing is displayed. By default, only the differences will be listed.

/s   Separator   : Compares all subkeys and entries.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg compare operation.

    Value

    Description

    0

    The comparison is successful and the result is identical.

    1

    The comparison failed.

    2

    The comparison is successful and differences were found.

Examples

The following example shows how you can use the reg compare command:

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

reg copy

Copies a registry entry to a specified location in the local or remote computer.

Syntax

reg copy KeyName1 KeyName2 [/s] [/f

Parameters

KeyName1   : Specifies the full path of the subkey to copy. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, you can use the HKLM and HKU subtrees only.

KeyName2   : Specifies the full path of the subkey destination. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, you can use the HKLM and HKU subtrees only.

/s   : Copies all subkeys and entries under the specified subkey.

/f   : Copies the subkey without asking for confirmation.

/? : Displays help at the command prompt.

Remarks

  • This version of Reg does not ask for confirmation when copying a subkey.

  • The following table lists the return values for the reg copy operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following examples show how you can 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

Deletes a subkey or entries from the registry.

Syntax

reg delete KeyName [{/v EntryName|/ve|/va}] [/f

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

/v   EntryName   : Deletes a specific entry under the subkey. If no entry is specified, then all entries and subkeys under the subkey will be deleted.

/ve   : Specifies that only entries that have no value will be deleted.

/va   : Deletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted with this parameter.

/f   : Deletes the existing registry subkey or entry without asking for confirmation.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg delete operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following examples show how you can 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 specified subkeys, entries, and values into a file so that it can be transferred to other servers.

Syntax

reg export KeyName FileName 

Parameters

KeyName   : Specifies the full path of the subkey. The export operation works only with the local computer. Start the path with the appropriate subtree. The valid subtrees 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.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg export operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg export command:

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

reg import

Copies a file containing exported registry subkeys, entries, and values into the local computer's registry.

Syntax

reg import FileName 

Parameters

FileName   : Specifies he name and path of the file that will be copied into the registry of the local computer. This file needs to be created beforehand with the reg export operation.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg import operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg import command:

reg import "hkcu\software\microsoft\winmine" c:\data\regbackups\wmbkup.reg

reg load

Writes saved subkeys and entries back to a different subkey in the registry. This is intended to be a temporary file that can be used for troubleshooting or editing registry entries.

Syntax

reg load KeyName FileName 

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

FileName   : Specifies the name and path of the file that will be loaded. This file must have been created with the reg save operation using a .hiv extension.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg load operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg load command:

reg load "hkcu\software\microsoft\winminebk2" wmbkup.hiv

reg query

Returns a list of the next tier of subkeys and entries located under a subkey in the registry.

Syntax

reg query KeyName [{/v EntryName|/ve}] [/s

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, you can use the HKLM and HKU subtrees only.

/v   EntryName   : Returns a specific entry and its value. This parameter only returns entries that are in the tier directly below the specified subkey. Entries that are located in subkeys under the current subkey will not be found. When EntryName is omitted, all entries under the subkey are returned.

/ve   : Specifies that only entries that have no value will be returned.

/s   : Returns all subkeys and entries in all tiers. Without this parameter, only the next tier of subkeys and entries will be returned.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg query operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following examples show how you can 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 saved subkeys and entries back to the registry.

Syntax

reg restore KeyName FileName 

Parameters

KeyName   : Specifies the full path of the subkey. The restore operation works only with the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

FileName   : Specifies the name and path of the file that will be written back to the registry. This file needs to be created beforehand with the reg save operation using a .hiv extension.

/? : Displays help at the command prompt.

Remarks

  • This operation is used to overwrite registry entries that have been edited. Before editing entries, save the parent subkey with the reg save operation. If the edit fails, restore the subkey with this operation.

  • The following table lists the return values for the reg restore operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg restore command:

reg restore "hkcu\software\microsoft\winmine" wmbkup.hiv

reg save

Saves a copy of specified subkeys, entries, and values of the registry in a specified file.

Syntax

reg save KeyName FileName 

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

FileName   : Specifies the name and path of the file that is created. If no path is specified, then the current path is used.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg save operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg save command:

reg save "hkcu\software\microsoft\winmine" wmbkup.hiv

reg unload

Removes a section of the registry that was loaded using the reg load operation.

Syntax

reg unload KeyName 

Parameters

KeyName   : Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC.

/? : Displays help at the command prompt.

Remarks

  • The following table lists the return values for the reg unload operation.

    Value

    Description

    0

    Success

    1

    Failure

Examples

The following example shows how you can use the reg unload command:

reg unload "hkcu\software\microsoft\winminebk2"

 Caution

  • Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

 Caution

  • Do not edit the registry directly unless you have no alternative. The registry editor bypasses standard safeguards, allowing settings that can degrade performance, damage your system, or even require you to reinstall Windows. You can safely alter most registry settings by using the programs in Control Panel or Microsoft Management Console (MMC). If you must edit the registry directly, back it up first. Read the Registry Editor Help for more information.

Remarks

  • Using Reg directly edits the registry of local or remote computers. These changes can render the computers inoperable and cause the need for a new installation of the operating system. Instead of directly editing the registry, use Control Panel or Microsoft Management Console, whenever possible, to make changes to the registry.

  • Some operations allow the viewing or configuration of registry entries on local or remote computers, while others allow only the configuration of local computers. Also, accessing the registry remotely might limit the parameters that you can use in an operation. Check the syntax for each operation to verify that it can be used on remote computers and to verify the parameters that can be used in that situation.

Formatting legend

Format

Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output