reg (查询,修改和操作Windows注册表)

方砖大叔 发表于 2020-06-17 18:01
浏览次数:
在手机上阅读

reg命令可以从命令行查询,修改和操作Windows注册表。

查看英文版

目录

1 reg 运行系统环境

2 reg 语法 Windows Vista, 7, 8, and 10

3 reg 语法 Windows XP

reg 运行系统环境

Windows xp

Windows vista

Windows 7

Windows 8

Windows 10

reg 语法 Windows Vista, 7, 8, and 10

REG Operation [Parameter...]

操作查询添加删除复制保存加载卸载恢复比较导出导入标记之一

参数在下面列出,并且根据“ 操作”而有所不同

所有操作(COMPARE除外的返回码成功都0失败1


QUERY operation
REG QUERY KeyName [{/v [ValueName]} | /ve] [/s] [/f Data [/k] [/d] [/c] [/e]]
          [/t Type] [/z] [/se Separator] [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。

FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
/v ValueName 查询特定的注册表项值。如果省略,则查询键的所有值。仅当使用搜索模式指定/ f选项时,才可以省略ValueName
/ve 查询默认值或空值名称(默认)。
/s 递归查询所有子项和值,类似于dir / s
/se Separator REG_MULTI_SZ的输入数据字符串中指定分隔符(仅1个字符的长度)默认为“ \ 0 ”(空字符)作为分隔符。
/f 指定要搜索的数据或模式。如果字符串包含空格,请使用双引号。默认值为“ * ”(通配符,表示任意数量的任何字符)。
/k 指定仅搜索键名。
/d 指定仅搜索键值数据。
/c 指定搜索区分大小写。(默认情况下,搜索不区分大小写。)
/e 指定仅返回完全匹配项。(默认情况下,将返回所有匹配项。)
/t 指定注册表值数据类型。有效类型为REG_SZREG_MULTI_SZREG_EXPAND_SZREG_DWORDREG_QWORDREG_BINARYREG_NONE(默认情况下,任何类型都是有效的结果。)
/z 详细:附加显示值名称类型的等效数字。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认是64位进程)访问密钥。

Examples:

REG QUERY HKLM\Software\Microsoft\ResKit /v Version

显示注册表值Version的

REG QUERY \\ABC\HKLM\Software\Microsoft\ResKit\Nt\Setup /s

显示远程计算机ABC上注册表项Setup下的所有子项和值

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /se #

对于所有类型为REG_MULTI_SZ的 值名称,显示所有以“  ”为分隔符的子项和值

REG QUERY HKLM /f SYSTEM /t REG_SZ /c /e

在数据类型REG_SZ的 HKLM根目录下 显示数据,并区分大小写并精确出现“ SYSTEM ” 

REG QUERY HKCU /f 0F /d /t REG_BINARY

显示,以及数据为“的出现0F ”在数据下HKCU根为数据类型REG_BINARY

REG QUERY HKLM\SOFTWARE /ve

HKLM \ SOFTWARE 显示空值(默认)的数据

ADD operation
REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
        [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
/v 要添加 的值名称,位于所选Key
/ve 查询默认值或空值名称(默认)。
/t Type 指定RegKey数据类型,其中TypeREG_SZREG_MULTI_SZREG_EXPAND_SZREG_DWORDREG_QWORDREG_BINARYREG_NONE之一如果省略,则假定为REG_SZ
/s Separator REG_MULTI_SZ的数据字符串中指定一个字符用作分隔符如果省略,则使用“ \ 0 ”(空字符)作为默认分隔符。
/d Data 要分配给注册表ValueName的数据
/f 强制覆盖现有注册表项,而无提示。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Examples:

REG ADD \\ABC\HKLM\Software\MyCo

在远程计算机ABC上添加密钥HKLM \ Software \ MyCo

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead

添加一个值(名称:数据,类型:REG_BINARY,数据:fe340ead)。

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail

添加一个值(名称:MRU,类型:REG_MULTI_SZ,数据:fax \ 0mail \ 0 \ 0)。

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%

添加一个值(名称:Path,类型:REG_EXPAND_SZ,数据:%systemroot%)。注意:使用扩展字符串内的脱字符号(^)。

DELETE operation
REG DELETE KeyName [/v ValueName | /ve | /va] [/f] [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
ValueName 所选键下的值名称要删除。省略时,将删除该键下的所有子键和值。
/ve 删除空值名称的值(默认)。
/va 删除此键下的所有值。
/f 强制删除而不提示。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Examples:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout

删除注册表项超时及其所有子项和值。

REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU

删除远程计算机ZODIACMyCo的注册表值MTU

COPY operation
REG COPY KeyName1 KeyName2 [/s] [/f] [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
/s 复制所有子项和值。
/f 强制复制而无提示。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Examples:

REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s

将键MyApp下的所有子键和值复制到键SaveMyApp

REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1

复制项下的所有值MYCOZODIAC到关键MyCo1在本地机器上。

SAVE operation
REG SAVE KeyName FileName [/y] [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
FileName 保存数据的目标文件。
/y 强制覆盖现有文件而无提示。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Example:

REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv

将配置单元MyApp保存当前目录中的文件AppBkUp.hiv中。

LOAD operation
REG LOAD KeyName FileName [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
FileName 要加载的配置单元文件的名称。您必须使用REG SAVE创建此文件。(请参阅上一节。)
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Example:

REG LOAD HKLM\TempHive TempHive.hiv

从文件TempHive.hiv(在当前目录中)将配置单元数据加载到注册表位置HKLM \ TempHive中

UNLOAD operation

UNLOAD删除使用LOAD操作加载的注册表部分

REG UNLOAD KeyName
KeyName 密钥名称,格式为ROOTKEY SubKeyROOTKEY必须是HKLMHKU之一SubKey是要卸载的配置单元的键名。

Example:

REG UNLOAD HKLM\TempHive

HKLM中 卸载配置单元TempHive

RESTORE operation
REG RESTORE KeyName FileName [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
FileName 要还原的配置单元文件的名称。您必须使用REG SAVE创建此文件。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。
REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv

还原配置单元文件NTRKBkUp.hiv,覆盖键ResKit

COMPARE operation
REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s]
            [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
ValueName 所选键下的值名称进行比较。省略时,将比较键下的所有值。
/ve 比较空值名称的值(默认)。
/s 比较所有子项和值。
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。
Output 输出类型。输出必须是/ oa/ od / os/ on之一

/ oa:输出所有差异和匹配项。
/ od:仅输出差异。(默认值。)
/ os:仅匹配输出。
/ on:无输出。

REG COMPARE的 返回码为

  • 0 结果相同
  • 1 无法进行比较.
  • 2 结果不相同

REG COMPARE输出的 每一行之前的符号

  • =在与FullKey2数据相同的FullKey1数据之前。
  • <在与FullKey2数据不同的FullKey1数据之前。
  • 在与Fullkey1数据不同的FullKey2数据之前。

Examples:

REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp

将键MyApp下的所有值SaveMyApp进行比较

REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version

比较MyCoMyCo1下的Version的值

REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s

ZODIACHKLM \ Software \ MyCo下的所有子项和值与本地计算机上的相同项进行比较。

EXPORT operation
REG EXPORT KeyName FileName [/y] [/reg:32 | /reg:64]
KeyName 密钥名称,格式为[ \\ Machine \ ] FullKey,其中Machine是远程计算机的可选名称。省略\\ Machine \默认为当前计算机。远程计算机上仅提供HKLM和HKU。
FullKey采用ROOTKEY SubKey的形式,其中ROOTKEYHKLMHKCUHKCRHKUHKCC之一,而SubKey是所选ROOTKEY下的注册表项的全名
FileName 要导出的磁盘文件的名称。
/y 强制覆盖现有文件而无提示。
/reg:32 指定应使用32位注册表视图访问密钥,这是32位进程的默认视图。
/reg:64 指定应使用64位注册表视图访问密钥,这是64位进程的默认视图。

Example:

REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg

将密钥MyApp的所有子项和值导出到文件AppBkUp.reg

IMPORT operation
REG IMPORT FileName [/reg:32 | /reg:64]
FileName The name of the file to import (local machine only).
/reg:32 指定应使用32位注册表视图(默认为32位进程)访问密钥。
/reg:64 指定应使用64位注册表视图(默认为64位进程)访问密钥。

Example:

REG IMPORT AppBkUp.reg

从文件AppBkUp.reg导入注册表项

FLAGS operation
REG FLAGS KeyName [QUERY | SET FlagName...] [/reg:32 | /reg:64]
KeyName 格式为HKLM \ Software [ SubKey ]的注册表项(此操作仅在本地计算机上可用。)SubKeyHKLM \ Software下注册表项的全名
QUERY 显示键KeyName的当前标志
SET FlagName... 设置键KeyName的标志FlagNameDONT_VIRTUALIZEDONT_SILENT_FAILRECURSE_FLAG的零个或多个如果指定SET参数,则将设置所有指定的FlagName,并且将清除所有未指定的FlagName
/reg:32 指定应使用32位注册表视图访问密钥。对于32位进程,此开关是默认设置。
/reg:64 指定应使用64位注册表视图访问密钥。对于64位进程,此开关是默认设置。

Examples:

REG FLAGS HKLM\Software\MyCo\MyApp QUERY

显示键MyApp的当前标志。

REG FLAGS HKLM\Software\MyCo\MyApp SET DONT_VIRTUALIZE /s

MyApp及其所有子项 设置DONT_VIRTUALIZE标志(并清除DONT_SILENT_FAILRECURSE_FLAG


REG Operation [Parameter...]

The Operation is one of QUERY, ADD, DELETE, COPY, SAVE, LOAD, UNLOAD, RESTORE, COMPARE, EXPORT, IMPORT, and FLAGS.

Parameters are listed below, and vary depending on Operation.

The return code for all operations (except COMPARE) is 0 for success or 1 for failure.

Note

For more information about the /reg:32 and /reg:64 parameters, including when to use them and how they interact with the registry, see this Microsoft support document.

QUERY operation
REG QUERY KeyName [{/v [ValueName]} | /ve] [/s] [/f Data [/k] [/d] [/c] [/e]]
          [/t Type] [/z] [/se Separator] [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
/v ValueName Queries for specific registry key values. If omitted, all values for the key are queried. ValueName can be omitted only when the /f option is specified with a pattern to search.
/ve Queries for the default value, or an empty value name (default).
/s Queries all subkeys and values recursively, similar to dir /s.
/se Separator Specifies the separator (length of 1 character only) in your in data string for REG_MULTI_SZ. Defaults to "\0" (null character) as the separator.
/f Specifies the data or pattern to be searched. Use double quotes if a string contains spaces. The default is "*" (the wildcard representing any number of any characters).
/k Specifies to search in key names only.
/d Specifies to search in key-value data only.
/c Specifies that the search is case-sensitive. (By default, searches are case-insensitive.)
/e Specifies to return only exact matches. (By default, all the matches are returned.)
/t Specifies registry value data type. Valid types are REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE. (By default, any type is a valid result.)
/z Verbose: Additionally shows the numeric equivalent for the type of the valuename.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view the бк default for 64-bit processes.

Examples:

REG QUERY HKLM\Software\Microsoft\ResKit /v Version

Displays the value of the registry value Version.

REG QUERY \\ABC\HKLM\Software\Microsoft\ResKit\Nt\Setup /s

Displays all subkeys and values under the registry key Setup on remote machine ABC.

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /se #

Displays all the subkeys and values with "#" as the separator, for all valuenames whose type is REG_MULTI_SZ.

REG QUERY HKLM /f SYSTEM /t REG_SZ /c /e

Displays Key, Value, and Data with case sensitive and exact occurrences of "SYSTEM" under HKLM root for the data type REG_SZ.

REG QUERY HKCU /f 0F /d /t REG_BINARY

Displays Key, Value, and Data for the occurrences of "0F" in data under HKCU root for the data type REG_BINARY.

REG QUERY HKLM\SOFTWARE /ve

Displays Value and Data for the empty value (the default) under HKLM\SOFTWARE.

ADD operation
REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
        [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
/v The value name, under the selected Key, to add.
/ve Queries for the default value, or empty value name (default).
/t Type Specify RegKey data type, where Type is one of REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY, or REG_NONE. If omitted, REG_SZ is assumed.
/s Separator Specify one character to use as the separator in the data string for REG_MULTI_SZ. If omitted, use "\0" (null character) is the default separator.
/d Data The data to assign to the registry ValueName being added.
/f Force overwriting the existing registry entry without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Examples:

REG ADD \\ABC\HKLM\Software\MyCo

Adds a key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead

Adds a value (name: Data, type: REG_BINARY, data: fe340ead).

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail

Adds a value (name: MRU, type: REG_MULTI_SZ, data: fax\0mail\0\0).

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%

Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%). Note: Use the caret symbol ( ^ ) inside the expand string.

DELETE operation
REG DELETE KeyName [/v ValueName | /ve | /va] [/f] [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
ValueName The value name, under the selected key, to delete. When omitted, all subkeys and values under the key are deleted.
/ve Delete the value of empty value name (default).
/va Delete all values under this key.
/f Forces the deletion without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Examples:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout

Deletes the registry key Timeout and of all its subkeys and values.

REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU

Deletes the registry value MTU under MyCo on remote machine ZODIAC.

COPY operation
REG COPY KeyName1 KeyName2 [/s] [/f] [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
/s Copies all subkeys and values.
/f Forces the copy without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Examples:

REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s

Copies all subkeys and values under the key MyApp to the key SaveMyApp.

REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1

Copies all values under the key MyCo on ZODIAC to the key MyCo1 on the local machine.

SAVE operation
REG SAVE KeyName FileName [/y] [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
FileName The destination file for the saved data.
/y Force overwriting the existing file without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Example:

REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv

Saves the hive MyApp to the file AppBkUp.hiv in the current directory.

LOAD operation
REG LOAD KeyName FileName [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
FileName The name of the hive file to load. You must use REG SAVE to create this file. (See the previous section.)
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Example:

REG LOAD HKLM\TempHive TempHive.hiv

Loads hive data from the file TempHive.hiv (in the current directory) into the registry location HKLM\TempHive.

UNLOAD operation

UNLOAD removes a section of the registry that was loaded using the LOAD operation.

REG UNLOAD KeyName
KeyName The name of a key in the form ROOTKEY\SubKey. ROOTKEY must be one of HKLM or HKU. SubKey is the key name of the hive to unload.

Example:

REG UNLOAD HKLM\TempHive

Unloads the hive TempHive in HKLM.

RESTORE operation
REG RESTORE KeyName FileName [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
FileName The name of the hive file to restore. You must use REG SAVE to create this file.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Example:

REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv

Restores the hive file NTRKBkUp.hiv, overwriting the key ResKit.

COMPARE operation
REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s]
            [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
ValueName The value name, under the selected key, to compare. When omitted, all values under the key are compared.
/ve Compare the value of empty value name (default).
/s Compare all subkeys and values.
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.
Output Output type. Output must be one of /oa, /od /os, or /on.

/oa: Output all differences and matches.
/od: Output only differences. (Default.)
/os: Output only matches.
/on: No output.

Return codes for REG COMPARE are:

  • 0 if the result compared is identical.
  • 1 if a comparison was impossible.
  • 2 if the result compared is different.

Symbols preceding each line of REG COMPARE's output:

  • = precedes FullKey1 data that is the same as FullKey2 data.
  • < precedes FullKey1 data that is different than FullKey2 data.
  • > precedes FullKey2 data that is different than Fullkey1 data.

Examples:

REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp

Compares all values under the key MyApp with SaveMyApp.

REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version

Compares the value of Version under the key MyCo and MyCo1.

REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s

Compares all subkeys and values under HKLM\Software\MyCo on ZODIAC with the same key on the local machine.

EXPORT operation
REG EXPORT KeyName FileName [/y] [/reg:32 | /reg:64]
KeyName The name of a key in the form of [\\Machine\]FullKey, where Machine is the optional name of a remote machine. Omitting \\Machine\ default to the current machine. Only HKLM and HKU are available on remote machines.

FullKey takes the form of ROOTKEY\SubKey where ROOTKEY is one of HKLM, HKCU, HKCR, HKU, or HKCC, and SubKey is the full name of a registry key under the selected ROOTKEY.
FileName The name of the disk file to export.
/y Force overwriting the existing file without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view, which is the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view, which is the default for 64-bit processes.

Example:

REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg

Exports all subkeys and values of the key MyApp to the file AppBkUp.reg

IMPORT operation
REG IMPORT FileName [/reg:32 | /reg:64]
FileName The name of the file to import (local machine only).
/reg:32 Specifies the key should be accessed using the 32-bit registry view бк the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view бк the default for 64-bit processes.

Example:

REG IMPORT AppBkUp.reg

Imports registry entries from the file AppBkUp.reg.

FLAGS operation
REG FLAGS KeyName [QUERY | SET FlagName...] [/reg:32 | /reg:64]
KeyName Registry key of the form HKLM\Software[\SubKey]. (This operation is available on local machines only.) SubKey is the full name of a registry key under HKLM\Software.
QUERY Display the current flags of key KeyName.
SET FlagName... Set flags for key KeyName. FlagName is zero or more of DONT_VIRTUALIZE, DONT_SILENT_FAIL, and RECURSE_FLAG. If the SET parameter is specified, any of these FlagNames specified will be set, and any not specified will be cleared.
/reg:32 Specifies the key should be accessed using the 32-bit registry view. This switch is the default for 32-bit processes.
/reg:64 Specifies the key should be accessed using the 64-bit registry view. This switch is the default for 64-bit processes.

Examples:

REG FLAGS HKLM\Software\MyCo\MyApp QUERY

Displays the current flags of the key MyApp.

REG FLAGS HKLM\Software\MyCo\MyApp SET DONT_VIRTUALIZE /s

Sets the DONT_VIRTUALIZE flag (and clears DONT_SILENT_FAIL and RECURSE_FLAG) on MyApp and all its subkeys.

有关/ reg:32和/ reg:64参数的更多信息,包括何时使用它们以及它们如何与注册表交互,请访问微软官方帮助。https://support.microsoft.com/en-us/help/305097/how-to-view-the-system-registry-by-using-64-bit-versions-of-windows

For more information about the /reg:32 and /reg:64 parameters, including when to use them and how they interact with the registry, see this Microsoft support document. https://support.microsoft.com/en-us/help/305097/how-to-view-the-system-registry-by-using-64-bit-versions-of-windows

查看英文版

查看中文版

reg 语法 Windows XP

REG Operation [Parameters]
Operation is one of QUERYADDDELETECOPYSAVELOADUNLOADRESTORECOMPAREEXPORT, and IMPORT. 参数  在下面列出,并根据“ 操作”而有所不同  。 The return code for all operations (except 所有操作(COMPARE除外)的返回码   成功都为  0或 失败为  1。 for failure. QUERY 操作(Windows XP)
REG QUERY KeyName [/v ValueName | /ve] [/s]
KeyName 格式[  Machine  ] FullKey的注册表项位置,其中  Machine  是远程计算机的名称。如果   省略 Machine ,则默认使用本地计算机。 FullKey  采用ROOTKEY  SubKey的形式  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。(只有  HKLM  和  HKU  在远程计算机上可用。)  SubKey  是所选项下注册表项的全名。 根密钥
/v 查询特定的注册表项。
ValueName 在所选键下要查询的名称。如果省略,则查询键下的所有值。
/ve 查询默认值或空值名称。
/s 查询所有子项和值。

ADD 操作 (Windows XP)

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
KeyName 格式[  Machine  ] FullKey的注册表项位置,其中  Machine  是远程计算机的名称。如果   省略 Machine ,则默认使用本地计算机。 FullKey  采用ROOTKEY  SubKey的形式  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。(只有  HKLM  和  HKU  在远程计算机上可用。)  SubKey  是所选项下注册表项的全名。 根密钥
/v ValueName ValueName  是在所选键下要添加的值名称。
/ve 为键添加一个空的值名称。
/t Type 指定要添加的数据类型。 类型  是  REG_SZ,  REG_MULTI_SZ,  REG_DWORD_BIG_ENDIAN,  REG_DWORD,  REG_BINARY,  REG_DWORD_LITTLE_ENDIAN,  REG_NONE和  REG_EXPAND_SZ之一。如果   省略Type, 则假定为  REG_SZ
/s Separator 指定一个字符  Separator,用作REG_MULTI_SZ数据字符串中的分隔符  。如果省略,请使用“ 0”(空字符)作为分隔符。
/d 要分配给注册表ValueName的数据。
/f 强制覆盖现有注册表项,而无提示。

 DELETE 操作(Windows XP)

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
KeyName 格式[ Machine ] FullKey的注册表项位置,其中  Machine  是远程计算机的名称。如果   省略 Machine ,则默认使用本地计算机。 FullKey  采用ROOTKEY SubKey的形式  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。(只有  HKLM  和  HKU  在远程计算机上可用。)  SubKey  是所选项下注册表项的全名。 根密钥。
ValueName 所选键下要删除的值名称,如果省略,将删除该键下的所有子键和值。
/ve 删除空值名称<无名称>的值
/va 删除此键下的所有值
/f 强制删除而不提示。

 COPY 操作 (Windows XP)

REG COPY KeyName1 KeyName2 [/s] [/f]
KeyName 格式[  Machine  ] FullKey的注册表项位置,其中  Machine  是远程计算机的名称。如果   省略 Machine ,则默认使用本地计算机。 FullKey  采用ROOTKEY  SubKey的形式  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。(只有  HKLM  和  HKU  在远程计算机上可用。)  SubKey  是所选项下注册表项的全名。 根密钥
/s 复制所有子项和值。
/f 强制复制而无提示。

 SAVE 操作 (Windows XP)

REG SAVE KeyName FileName
KeyName 格式为ROOTKEY SubKey的注册表项名称  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。 SubKey  是所选ROOTKEY下的注册表项的全名  。
FileName 将在其中保存数据的文件的名称。如果未指定路径,则在当前目录中创建文件。

 RESTORE 操作 (Windows XP)

REG RESTORE KeyName FileName
KeyName ROOTKEY  SubKey  (仅本地计算机。)  ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。 SubKey  是注册表项的全名,应该在其中存储配置单元文件的数据,从而覆盖现有项的值和子项。
FileName 要还原的配置单元文件的名称。您必须使用  REG SAVE  创建此文件。

 LOAD 操作 (Windows XP)

REG LOAD KeyName FileName
KeyName Key 形式键名  ROOTKEY  子密钥  (本地计算机只)  ROOTKEY  是  HKLM  或  HKU。
SubKey 将在其中配置单元文件数据的密钥名称,从而创建一个新密钥。
FileName 要加载的配置单元文件的名称。您必须使用  REG SAVE  创建此文件。

 UNLOAD 操作 (Windows XP)

REG UNLOAD KeyName
KeyName 格式为ROOTKEY  SubKey的密钥名称   (仅本地计算机)  ROOTKEY  是  HKLM  或  HKU,而  SubKey  是要卸载的配置单元的密钥名称。

 COMPARE 操作 (Windows XP)

REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s]
KeyName1KeyName2 格式为[  Machine  ] FullKey的注册表项位置,其中  Machine  是远程计算机的名称。如果   省略 Machine ,则默认使用本地计算机。 FullKey  采用ROOTKEY  SubKey的形式  。 ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。(只有  HKLM  和  HKU  在远程计算机上可用。)  FullKey  的格式为  ROOTKEY SubKey,其中  SubKey  是ROOTKEY下的注册表项的全名  。如果  FullKey2  被省略,  FullKey2  是一样的  FullKey1
/v ValueName ValueName  是在所选键下要比较的值名称。省略时,将比较键下的所有值。
/ve 比较空值名称的值。
/s 比较所有子项和值。
Output 输出类型,/ oa,  / od,  / os  / on

/oa: 输出所有差异和匹配项。
/od: 仅输出差异(默认)。
/os: 仅输出匹配项。
/on: 无输出。
Return codes for REG COMPARE are:
  • 0: 比较项目相同。
  • 1: 比较失败。
  • 2: 比较项目不同。

EXPORT 操作 (Windows XP)

REG EXPORT KeyName FileName
Keyname Key ROOTKEY  SubKey的键名  。(仅限本地计算机。)  ROOTKEY  是  HKLM,  HKCU,  HKCR,  HKU和  HKCC之一。 SubKey  是所选ROOTKEY下的注册表项的全名  。
FileName 要导出的磁盘文件的名称

 IMPORT 操作 (Windows XP)

REG IMPORT FileName

FileName  要导入的磁盘文件的名称(仅本地计算机)。


示例

以下示例使用Windows Vista,7、8和10中的reg语法。

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s
显示注册表值Version的值  。
REG QUERY HKLMSoftwareMicrosoftResKitNtSetup /s
显示注册表项Setup下的所有子项和值  。
REG ADD \\ABC\HKLM\Software\MyCo
在远程计算机ABC上添加密钥HKLM Software MyCo  。
REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
添加一个值(名称:  Data,类型:  REG_BINARY,数据:  fe340ead)。
REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
添加一个值(名称:  MRU,类型:  REG_MUTLI_SZ,数据:  Fax  0 mail)。
REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%
添加一个值(名称:  Path,类型:  REG_EXPAND_SZ,数据:  %systemroot%)。注意: 在扩展字符串中使用双百分数(  %%)。
REG DELETE HKLM\Software\MyCo\MyApp\Timeout
删除注册表项  超时  及其所有子项和值。
REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
删除注册表值  MTU  下  MYCO  上  ZODIAC
REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s
将键MyApp下的所有子键和值复制   到键  SaveMyApp
REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1
复制项下的所有值  MYCO  上  ZODIAC  到关键  MyCo1  在当前机器上。
REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv

将配置单元MyApp保存   到 当前文件夹中的文件  AppBkUp.hiv中。

REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv
恢复文件  NTRKBkUp.hiv  覆盖键  ResKit
REG LOAD HKLM\TempHive TempHive.hiv
将文件TempHive.hiv加载   到密钥  HKLM TempHive中
REG UNLOAD HKLM\TempHive
在  HKLM中 卸载配置单元  TempHive
REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp
将键MyApp下的所有值   与  SaveMyApp比较
REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version
比较键MyCo  和  MyCo1下的值Version。 
REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s
ZODIAC  上  HKLM Software MyCo下的所有子项和值   与当前计算机上的相同项进行比较。
REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg
将密钥MyApp的所有子项和值导出   到文件  AppBkUp.reg中
REG IMPORT AppBkUp.reg
从文件AppBkUp.reg导入注册表项  。
REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s
显示注册表值Version的值  。
REG QUERY HKLMSoftwareMicrosoftResKitNtSetup /s
显示注册表项Setup下的所有子项和值  。
REG ADD \\ABC\HKLM\Software\MyCo
在远程计算机ABC上添加密钥HKLM Software MyCo  。
REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
添加一个值(名称:  Data,类型:  REG_BINARY,数据:  fe340ead)。
REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
添加一个值(名称:  MRU,类型:  REG_MUTLI_SZ,数据:  Fax  0 mail)。
REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%
添加一个值(名称:  Path,类型:  REG_EXPAND_SZ,数据:  %systemroot%)。注意: 在扩展字符串中使用双百分数(  %%)。
REG DELETE HKLM\Software\MyCo\MyApp\Timeout
删除注册表项  超时  及其所有子项和值。
REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
删除注册表值  MTU  下  MYCO  上  ZODIAC
REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s
将键MyApp下的所有子键和值复制   到键  SaveMyApp
REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1
复制项下的所有值  MYCO  上  ZODIAC  到关键  MyCo1  在当前机器上。
REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv

将配置单元MyApp保存   到 当前文件夹中的文件  AppBkUp.hiv中。

REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv
恢复文件  NTRKBkUp.hiv  覆盖键  ResKit
REG LOAD HKLM\TempHive TempHive.hiv
将文件TempHive.hiv加载   到密钥  HKLM TempHive中
REG UNLOAD HKLM\TempHive
在  HKLM中 卸载配置单元  TempHive
REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp
将键MyApp下的所有值   与  SaveMyApp比较
REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version
比较键MyCo  和  MyCo1下的值Version。 
REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s
ZODIAC  上  HKLM Software MyCo下的所有子项和值   与当前计算机上的相同项进行比较。
REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg
将密钥MyApp的所有子项和值导出   到文件  AppBkUp.reg中
REG IMPORT AppBkUp.reg
从文件AppBkUp.reg导入注册表项  。
REG Operation [Parameters]

Operation is one of QUERYADDDELETECOPYSAVELOADUNLOADRESTORECOMPAREEXPORT, and IMPORT.

Parameters are listed below and vary depending on Operation.

The return code for all operations (except COMPARE) is 0 for success or 1 for failure.

QUERY operation (Windows XP)

REG QUERY KeyName [/v ValueName | /ve] [/s]
KeyName Registry key location of the form [Machine]FullKey, where Machine is the name of a remote machine. If Machine is omitted, the local machine is used by default. FullKey takes the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCC. (Only HKLM and HKU are available on remote machines.) SubKey is the full name of a registry key under the selected ROOTKEY.
/v Query for a specific registry key.
ValueName The name, under the selected key, to query. If omitted, all values under the key are queried.
/ve Query the default value or empty value name.
/s Query all subkeys and values.

ADD operation (Windows XP)

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
KeyName Registry key location of the form [Machine]FullKey, where Machine is the name of a remote machine. If Machine is omitted, the local machine is used by default. FullKey takes the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCC. (Only HKLM and HKU are available on remote machines.) SubKey is the full name of a registry key under the selected ROOTKEY.
/v ValueName ValueName is the value name, under the selected key, to add.
/ve Adds an empty value namefor the key.
/t Type Specify the type of data to add. Type is one of REG_SZREG_MULTI_SZREG_DWORD_BIG_ENDIANREG_DWORDREG_BINARYREG_DWORD_LITTLE_ENDIANREG_NONE, and REG_EXPAND_SZ. If Type is omitted, REG_SZ is assumed.
/s Separator Specify a single character, Separator, to use as the separator in your data string for REG_MULTI_SZ. If omitted, use "" (the null character) as the separator.
/d The data to assign to the registry ValueName being added.
/f Force overwriting the existing registry entry without prompt.

DELETE operation (Windows XP)

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
KeyName Registry key location of the form [Machine]FullKey, where Machine is the name of a remote machine. If Machine is omitted, the local machine is used by default. FullKey takes the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCC. (Only HKLM and HKU are available on remote machines.) SubKey is the full name of a registry key under the selected ROOTKEY.
ValueName The value name, under the selected key, to delete when omitted, all subkeys and values under the key are deleted.
/ve Delete the value of empty value name
/va Delete all values under this key
/f Force the deletion without prompt.

COPY operation (Windows XP)

REG COPY KeyName1 KeyName2 [/s] [/f]
KeyName Registry key location of the form [Machine]FullKey, where Machine is the name of a remote machine. If Machine is omitted, the local machine is used by default. FullKey takes the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCC. (Only HKLM and HKU are available on remote machines.) SubKey is the full name of a registry key under the selected ROOTKEY.
/s Copy all subkeys and values.
/f Force the copy without prompt.

SAVE operation (Windows XP)

REG SAVE KeyName FileName
KeyName Registry key name of the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCCSubKey is the full name of a registry key under the selected ROOTKEY.
FileName The name of the file where the data will be saved. If no path is specified, the file is created in the current directory.

RESTORE operation (Windows XP)

REG RESTORE KeyName FileName
KeyName ROOTKEYSubKey (local machine only.) ROOTKEY is one of HKLMHKCUHKCRHKU, and HKCCSubKey is the full name of a registry key where the hive file's data should be stored, overwriting the existing key's values and subkeys.
FileName The name of the hive file to restore. You must use REG SAVE to create this file.

LOAD operation (Windows XP)

REG LOAD KeyName FileName
KeyName Key name in the form ROOTKEYSubKey (local machine only) ROOTKEY is HKLM or HKU.
SubKey The name of the key where the hive file's data will be loaded, creating a new key.
FileName The name of the hive file to load. You must use REG SAVE to create this file.

UNLOAD operation (Windows XP)

REG UNLOAD KeyName
KeyName Key name in the form ROOTKEYSubKey (local machine only) ROOTKEY is HKLM or HKU, and SubKey is the key name of the hive to unload.

COMPARE operation (Windows XP)

REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s]
KeyName1KeyName2 Registry key locations of the form [Machine]FullKey, where Machine is the name of a remote machine. If Machine is omitted, the local machine is used by default. FullKey takes the form ROOTKEYSubKeyROOTKEY is one of HKLMHKCUHKCRHKU, and HKCC. (Only HKLM and HKU are available on remote machines.) FullKey takes the form ROOTKEYSubKey, where SubKey is the full name of a registry key under ROOTKEY. If FullKey2 is omitted, FullKey2 is the same as FullKey1.
/v ValueName ValueName is the value name, under the selected key, to compare. When omitted, all values under the key are compared.
/ve Compare the value of empty value name.
/s Compare all subkeys and values.
Output Output type, which is one of /oa/od/os, and /on.

/oa: Output all differences and matches.
/od: Output only differences (default).
/os: Output only matches.
/on: No output.

Return codes for REG COMPARE are:

  • 0: compared items are identical.
  • 1: comparison failed.
  • 2: compared items are different.

EXPORT operation (Windows XP)

REG EXPORT KeyName FileName
Keyname Key name of the form ROOTKEYSubKey. (Local machine only.) ROOTKEY is one of HKLMHKCUHKCRHKU, and HKCCSubKey is the full name of a registry key under the selected ROOTKEY.
FileName The name of the disk file to export.

IMPORT operation (Windows XP)

REG IMPORT FileName
FileName The name of the disk file to import (local machine only).

Examples

The following examples use the modern reg syntax found in Windows Vista, 7, 8, and 10.

REG QUERY HKLMSoftwareMicrosoftResKit /v Version

Displays the value of the registry value Version.

REG QUERY HKLMSoftwareMicrosoftResKitNtSetup /s

Displays all subkeys and values under the registry key Setup.

REG ADD ABCHKLMSoftwareMyCo

Adds a key HKLMSoftwareMyCo on remote machine ABC.

REG ADD HKLMSoftwareMyCo /v Data /t REG_BINARY /d fe340ead

Adds a value (name: Data, type: REG_BINARY, data: fe340ead).

REG ADD HKLMSoftwareMyCo /v MRU /t REG_MULTI_SZ /d faxmail

Adds a value (name: MRU, type: REG_MUTLI_SZ, data: faxmail).

REG ADD HKLMSoftwareMyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%

Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%). Note: Use the double percentage ( %% ) inside the expand string.

REG DELETE HKLMSoftwareMyCoMyAppTimeout

Deletes the registry key Timeout and its all subkeys and values.

REG DELETE ODIACHKLMSoftwareMyCo /v MTU

Deletes the registry value MTU under MyCo on ZODIAC.

REG COPY HKLMSoftwareMyCoMyApp HKLMSoftwareMyCoSaveMyApp /s

Copies all subkeys and values under the key MyApp to the key SaveMyApp.

REG COPY ODIACHKLMSoftwareMyCo HKLMSoftwareMyCo1

Copies all values under the key MyCo on ZODIAC to the key MyCo1 on the current machine.

REG SAVE HKLMSoftwareMyCoMyApp AppBkUp.hiv

Saves the hive MyApp to the file AppBkUp.hiv in the current folder.

REG RESTORE HKLMSoftwareMicrosoftResKit NTRKBkUp.hiv

Restores the file NTRKBkUp.hiv overwriting the key ResKit.

REG LOAD HKLMTempHive TempHive.hiv

Loads the file TempHive.hiv to the key HKLMTempHive.

REG UNLOAD HKLMTempHive

Unloads the hive TempHive in HKLM.

REG COMPARE HKLMSoftwareMyCoMyApp HKLMSoftwareMyCoSaveMyApp

Compares all values under the key MyApp with SaveMyApp

REG COMPARE HKLMSoftwareMyCo HKLMSoftwareMyCo1 /v Version

Compares the value Version under the key MyCo and MyCo1

REG COMPARE ODIACHKLMSoftwareMyCo . /s

Compares all subkeys and values under HKLMSoftwareMyCo on ZODIAC with the same key on the current machine.

REG EXPORT HKLMSoftwareMyCoMyApp AppBkUp.reg

Exports all subkeys and values of the key MyApp to the file AppBkUp.reg.

REG IMPORT AppBkUp.reg

Imports registry entries from the file AppBkUp.reg.

查看英文版

查看中文版

其他命令行

rd/rmdir | ren | robocopy | route | runas |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条