大网数据广告活动
Windows排障命令

reg add

· 52CE 我爱测

Reference article for the reg add command, which adds a new subkey or entry to the registry.

Adds a new subkey or entry to the registry.

Syntax

reg add <keyname> [/v valuename | /ve] [/t datatype] [/s separator] [/d data] [/f] [/reg:32 | /reg:64]

Parameters

Parameter Description
<keyname> Specifies the full path of the subkey or entry to be added. To specify a remote computer, include the computer name (in the format \\<computername>\) as part of the keyname. Omitting \\<computername>\ causes the operation to default to the local computer. The keyname must include a valid root key. Valid root keys for the local computer are: <ul><li>HKCR (HKEY_CLASSES_ROOT) <li>HKCU (HKEY_CURRENT_USER)<li>HKLM (HKEY_LOCAL_MACHINE) <li> HKU (HKEY_USERS) <li>HKCC (HKEY_CURRENT_CONFIG) </ul></li>If a remote computer is specified, valid root keys are: HKLM and HKU. If the registry key name contains a space, enclose the key name in quotes.
/v <Valuename> Specifies the name of the add registry entry.
/ve Specifies that the added registry entry has a null value.
/t <Type> Specifies the type for the registry entry. Type must be one of the following:<ul><li>REG_SZ</li><li>REG_MULTI_SZ</li><li>REG_DWORD_BIG_ENDIAN</li><li>REG_DWORD</li><li>REG_BINARY</li><li>REG_DWORD_LITTLE_ENDIAN</li><li>REG_LINK</li><li>REG_FULL_RESOURCE_DESCRIPTOR</li><li>REG_EXPAND_SZ</li></ul>
/s <Separator> Specifies the character to be used to separate multiple instances of data when the REG_MULTI_SZ data type is specified and more than one entry is listed. If not specified, the default separator is \0.
/d <Data> Specifies the data for the new registry entry.
/f Adds the registry entry without prompting for confirmation.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64 Specifies the key should be accessed using the 64-bit registry view.
/? Displays help at the command prompt.
Remarks
  • Subtrees can't be added with this operation. This version of reg doesn't ask for confirmation when adding a subkey.

  • The return values for the reg add operation are:

Value Description
0 Success
1 Failure
  • For the REG_EXPAND_SZ key type, use the caret symbol ( ^ ) with % inside the /d parameter.

Examples

To add the key HKLM\Software\MyCo on remote computer ABC, type:

reg add \\ABC\HKLM\Software\MyCo

To add a registry entry to HKLM\Software\MyCo with a value named Data, the type REG_BINARY, and data of fe340ead, type:

reg add HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead

To add a multi-valued registry entry to HKLM\Software\MyCo with a value named MRU, the type REG_MULTI_SZ, and data of fax\0mail\0, type:

reg add HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail\0

To add an expanded registry entry to HKLM\Software\MyCo with a value named Path, the type REG_EXPAND_SZ, and data of %systemroot%, type:

reg add HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 01/04/2024
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。