Windows 注册表是安装在所有版本的(Windows Registry)Microsoft Windows操作系统 上的软件和硬件的信息、设置、选项和其他值的数据库 。安装程序时,会在注册表中创建一个新的子项。此子项包含特定于该程序的设置,例如其位置、版本和主要可执行文件。Windows 和许多第三方应用程序将设置存储在注册表中。在这篇文章中,我们将向您展示如何在Windows 10中从(Windows 10)命令提示符(Command Prompt)编辑注册表。
从命令提示符编辑注册表
添加(Adding)、修改或删除Windows注册表子项和值只能由高级用户、管理员和 IT 专业人员完成。在进行更改之前要小心。由于这是注册表操作,建议您备份注册表(back up the registry) 或 创建系统还原点 ,以防程序出错。
采取必要的预防措施后,您可以进行以下操作:
按Windows键 + R 调用“运行”(Run)对话框。
在“运行”对话框中,键入cmd,然后按CTRL + SHIFT + ENTER以在管理员模式下打开命令提示符(open Command Prompt in admin mode)。
要获取操作列表,请运行以下命令:
REG /?
将出现操作列表(Operation List)以及每个命令的返回代码(Return Code)。
以下是Microsoft 所述(described by Microsoft)的操作列表以及每个操作的功能 :
- 添加:(Add:) 向注册表添加新的子项或条目。
- 比较:(Compare:) 比较指定的注册表子项或条目。
- 复制:(Copy:) 将注册表项复制到本地或远程计算机上的指定位置。
- 删除:(Delete:) 删除子项或条目。
- 导出:(Export:) 将本地计算机的指定子键、条目和值复制到文件中,以便传输到其他服务器。
- 导入:(Import:) 将包含导出的注册表子项、条目和值的文件的内容复制到本地计算机的注册表中。
- 加载:(Load:) 将保存的子项和条目写入注册表中的不同子项。这旨在与用于故障排除或编辑注册表项的临时文件一起使用。
- 查询:(Query:) 返回位于注册表中指定子项下的下一层子项和条目的列表。
- 恢复:(Restore:) 将保存的子项和条目写回注册表。
- 保存:(Save:) 将注册表的指定子项、条目和值的副本保存在指定文件中。
- 卸载:(Unload:) 删除使用该
REG LOAD
操作加载的注册表部分。
并且,返回码:
要获得特定操作的帮助,请将操作名称附加到上一个命令的中间:
REG <Operation> /?
例如,如果您需要有关添加(Add)操作的帮助,请运行以下命令:
REG ADD /?
当命令执行时,将返回您需要的有关指定操作的所有信息,包括语法、参数,甚至一些示例。
现在我们已经了解了关于REG ADD的所有信息,让我们尝试将其付诸实践。
向注册表添加子项(SubKey)或条目(Entry)
首先,下面是使用REG ADD /?ADD语法。(REG ADD)命令:
REG ADD <KeyName> [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]
<KeyName>指定子项的完整路径。本地计算机的有效根密钥是HKLM、HKCU、HKCR、HKU和HKCC。您可以将HKLM和HKU根密钥用于远程计算机。/v <ValueName>指定要在指定子项下添加的注册表项的名称。稍后我们将定义其余参数,但对于本示例,这就是我们所需要的。
因此,假设我们要在HKLM\Software下添加一个名为TheWindowsClubSubkey的子项,命令(语法)将如下所示:
REG ADD HKLM\Software\TheWindowsClubSubkey
一旦命令执行,子项将被添加到注册表中。要确认,请执行以下操作:
- 按Windows键 + R 调用“运行”(Run)对话框。
- 在“运行”对话框中,键入regedit并按 Enter 以打开注册表编辑器(open Registry Editor)。
- 导航或跳转到下面的注册表项路径:
HKEY_LOCAL_MACHINE > SOFTWARE > TheWindowsClubSubkey
从注册表中删除(Delete)子键(SubKey)或条目
要从注册表中删除子项或条目,请运行以下语法:
REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]
因此,假设我们要删除/移除HKLM\Software下名为TheWindowsClubSubkey的子项,命令(语法)将如下所示:
REG DELETE HKLM\Software\TheWindowsClubSubkey
如果您真的要删除子项,系统会提示您。键入是(Yes),然后按 Enter。
一旦命令执行,子项将从注册表中删除。
这就是如何从 Windows 10 中的命令提示符编辑注册表。(That’s it on how to edit the Registry from Command Prompt in Windows 10.)
How to edit the Registry from Command Prompt in Windows 10
Τhе Windows Registry is a database of information, settings, options, and other values for software and hardware installed on all versions of Microsoft Windows operating systems. When a program is installed, a new subkey is created in the registry. This subkey contains settings specific to that program, such as its location, version, and primary executable. Windows and a lot of third-party apps store settings in the registry. In this post, we will show you how to edit the Registry from Command Prompt in Windows 10.
Edit Registry from Command Prompt
Adding, modifying, or deleting Windows registry subkeys and values should only be done by advanced users, admins, and IT professionals. Take caution before you make changes. Since this is a registry operation, it is recommended that you back up the registry or create a system restore point in case the procedure goes wrong.
Once you have taken the necessary precautionary measures, you can proceed as follows:
Press Windows key + R to invoke the Run dialog.
In the Run dialog box, type cmd and then press CTRL + SHIFT + ENTER to open Command Prompt in admin mode.
To get the list of operations, run command the command below:
REG /?
The Operation List will appear, as well as the Return Code for each command.
Here’s the list of operations and what each does, as described by Microsoft:
- Add: Adds a new subkey or entry to the registry.
- Compare: Compares specified registry subkeys or entries.
- Copy: Copies a registry entry to a specified location on a local or remote machine.
- Delete: Deletes a subkey or entries.
- Export: Copies the specified subkeys, entries, and values of the local computer into a file for transfer to other servers.
- Import: Copies the contents of a file that contains exported registry subkeys, entries, and values into the registry of the local computer.
- Load: Writes saved subkeys and entries into a different subkey in the registry. This is intended to be used with temp files that are used for troubleshooting or editing registry entries.
- Query: Returns a list of the next tier of subkeys and entries that are located und a specified subkey in the registry.
- Restore: Writes saved subkeys and entries back to the registry.
- Save: Saves a copy of specified subkeys, entries, and values of the registry in a specified file.
- Unload: Removes a section of the registry that was loaded using the
REG LOAD
operation.
And, the return codes:
To get help for with a specific operation, append the operation name to the middle of the previous command:
REG <Operation> /?
Example, if you wanted help on the Add operation, run the following command:
REG ADD /?
When the command executes, all of the information that you need about the specified operation is returned, including the syntax, parameters, and even some examples.
Now that we know all that we need to know about REG ADD, let’s try to put it in action.
Add a SubKey or Entry to the Registry
To begin, below is the syntax for REG ADD from using the REG ADD /? command:
REG ADD <KeyName> [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]
The <KeyName> specifies the full path of the subkey. Valid root keys for the local computer are HKLM, HKCU, HKCR, HKU, and HKCC. You can use the HKLM and HKU root keys for remote computers. The /v <ValueName> specifies the name of the registry entry to be added under the specified subkey. We’ll define the rest of the parameters later, but for this example, this is all we’ll need.
So, let’s say we want to add a subkey named TheWindowsClubSubkey under HKLM\Software, the command (syntax) will look like this:
REG ADD HKLM\Software\TheWindowsClubSubkey
Once the command executes the subkey will be added to the registry. To confirm do the following:
- Press Windows key + R to invoke the Run dialog.
- In the Run dialog box, type regedit and hit Enter to open Registry Editor.
- Navigate or jump to the registry key path below:
HKEY_LOCAL_MACHINE > SOFTWARE > TheWindowsClubSubkey
Delete a SubKey or Entry from the Registry
To delete a subkey or entry from the registry, run the following syntax:
REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]
So, let’s say we want to delete/remove the subkey named TheWindowsClubSubkey under HKLM\Software, the command (syntax) will look like this:
REG DELETE HKLM\Software\TheWindowsClubSubkey
You’ll be prompted if you really want to delete the subkey. Type Yes and hit Enter.
Once the command executes the subkey will be deleted from the registry.
That’s it on how to edit the Registry from Command Prompt in Windows 10.