注册表关闭命令提示符_如何从命令提示符下编辑Windows注册表

注册表关闭命令提示符

注册表关闭命令提示符

Microsoft Windows 10 Logo

Windows and a lot of third-party apps store settings in the registry. If you’re wanting to edit the registry, there are a few ways you can do it. Here’s how to edit the Windows registry from the Command Prompt.

Windows和许多第三方应用程序将设置存储在注册表中。 如果要编辑注册表,可以通过几种方法进行。 这是从命令提示符处编辑Windows注册表的方法。

Before we get started, it’s important that you back up the registry, as well as your computer, before you make any edits. One wrong move can make your system unstable or even completely inoperable. You can also create a System Restore point to quickly roll back your system if something goes wrong.

在开始之前,重要的是在进行任何编辑之前,请备份注册表 以及计算机 。 一个错误的举动可能会使您的系统不稳定,甚至完全无法运行。 您还可以创建系统还原点,以在出现问题时快速回滚系统。

Microsoft themselves publicly state that 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.

Microsoft自己公开声明,添加,修改或删除Windows注册表子项和值仅应由高级用户,管理员和IT专业人员完成。 进行更改之前请多加注意。

在命令提示符下编辑Windows注册表 (Edit the Windows Registry from the Command Prompt)

There’s a long list of reg operations. We’ll give a couple of examples of how to execute basic operations. If you’re interested in the full list of operations, each syntax, and what the parameters within each syntax represents, check out the list at the bottom of the article.

reg操作列表很长。 我们将给出一些有关如何执行基本操作的示例。 如果您对操作的完整列表,每种语法以及每种语法中的参数表示感兴趣,请查看本文底部的列表。

Once you’re ready to edit the Windows Registry, open the Command Prompt as an administrator.

准备好编辑Windows注册表后, 以管理员身份打开命令提示符

以管理员身份打开命令提示符 (Open the Command Prompt as Admin)

To open the Command Prompt as an admin, type “cmd” in the Windows search bar.

要以管理员身份打开命令提示符,请在Windows搜索栏中键入“ cmd”。

search cmd in windows search bar

Next, right-click the “Command Prompt” app in the search results, and select “Run As Administrator” from the menu.

接下来,右键单击搜索结果中的“命令提示符”应用,然后从菜单中选择“以管理员身份运行”。

Command Prompt app in windows search

Command Prompt will now open in admin mode, and we can begin editing the Windows registry.

现在,命令提示符将在管理模式下打开,我们可以开始编辑Windows注册表。

了解操作类型 (Learn the Operation Types)

We’ll give a full list of the reg commands and each respective syntax later. For now, you can get a list of the operation types, as well as additional help with each operation, from the Command Prompt.

稍后,我们将提供reg命令的完整列表以及每个语法。 现在,您可以从命令提示符处获得操作类型的列表以及每个操作的其他帮助。

To get the list of operations, run this command:

要获取操作列表,请运行以下命令:

REG /?

The Operation List will appear, as well as the Return Code for each command.

将显示操作列表以及每个命令的返回码。

Command to get list of operations

Here’s the list of operations and what each does, as described by Microsoft:

这是操作的列表以及每个操作的作用,如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.

    卸载:删除使用REG LOAD加载的注册表部分。   操作。

And, the return codes:

并且,返回码:

  • 0: Successful

    0:成功

  • 1: Failed

    1:失败

To get help for with a specific operation, append the operation name to the middle of the previous command:

要获得有关特定操作的帮助,请将操作名称附加到上一个命令的中间:

REG <Operation> /?

So, if I wanted help on the “Add” operation, I would run:

因此,如果我需要有关“添加”操作的帮助,则可以运行:

REG ADD /?

Run command to get help on a specific operation

As you can see, 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.

现在我们已经了解了有关REG ADD所有知识,让我们尝试将其付诸实践。

将子项或项添加到注册表 (Add a SubKey or Entry to the Registry)

First things first, here’s the syntax for REG ADD that we retrieved from using the REG ADD /? command:

首先最重要的,下面是语法REG ADD ,我们从使用检索到的REG ADD /? 命令:

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. /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.

<KeyName>指定子项的完整路径。 本地计算机的有效根密钥为HKLM,HKCU,HKCR,HKU和HKCC。 您可以将HKLM和HKU根密钥用于远程计算机。 /v <ValueName>指定要在指定子项下添加的注册表项的名称。 稍后我们将定义其余参数,但是对于本示例,这就是我们所需要的。

So, let’s say we want to add a subkey named HowToGeekSubkey under HKEY_LOCAL_MACHINE\Software. We’ll run the following command:

因此,假设我们要在HKEY_LOCAL_MACHINE \ Software下添加一个名为HowToGeekSubkey的子项。 我们将运行以下命令:

REG ADD HKLM\Software\HowToGeekSubkey

If the operation was successfully executed, the Command Prompt will let you know.

如果操作成功执行,命令提示符将通知您。

command for adding a subkey to the registry

If you want to double-check that the operation was successful, you can look for yourself using the Registry Editor.

如果要再次检查操作是否成功,可以使用注册表编辑器查找自己。

Open the Registry Editor by typing “regedit” in the Windows search bar and selecting the Registry Editor app.

打开注册表编辑器通过键入“REGEDIT”,在Windows搜索栏并选择注册表编辑器应用程序。

open registry editor

Navigate to the location of the newly added subkey. In our case: HKEY_LOCAL_MACHINE > SOFTWARE > HowToGeekSubkey.

导航到新添加的子项的位置。 在我们的示例中:HKEY_LOCAL_MACHINE>软件> HowToGeekSubkey。

How to geek subkey in registry

Now that we’ve confirmed it’s there, let’s delete it.

现在我们已经确认了它的存在,让我们删除它。

从注册表中删除子项或条目 (Delete a Subkey or Entry from the Registry)

Here’s the syntax for the REG DELETE operation:

这是REG DELETE操作的语法:

REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]

The parameters that we care about for now are the same as before. That is, <KeyName> and /v valuename.

我们现在关心的参数与以前相同。 即<KeyName>/v valuename

If we want to delete the HowToGeekSubkey subkey from HKEY_LOCAL_MACHINE\Software that we just created, we will run this command:

如果要从刚刚创建的HKEY_LOCAL_MACHINE \ Software中删除HowToGeekSubkey子项,我们将运行以下命令:

REG DELETE HKLM\Software\HowToGeekSubkey

This time, you’ll be asked if you really want to delete the subkey. Type Yes and press “Enter.”

这次,系统将询问您是否确实要删除子项。 输入Yes ,然后按“ Enter”。

Again, the Command Prompt will let you know if the operation was executed successfully.

同样,命令提示符将让您知道操作是否成功执行。

Delete subkey from registry

You can cross-verify that the subkey was actually deleted from the Registry Editor. Navigate to the location that the subkey used to live and see if it was removed.

您可以交叉验证该子项是否实际上已从注册表编辑器中删除。 导航到该子项曾经居住的位置,并查看是否已将其删除。

REG操作,语法和参数说明 (REG Operations, Syntax, and Parameter Descriptions)

Though we only covered two simple examples, there’s a decent-sized list of REG operations. Each operation can have a potentially complex syntax. For easy access, we’ll list out all the details provided by Microsoft here.

尽管我们仅介绍了两个简单的示例,但仍有相当大的REG操作列表。 每个操作都可能具有潜在的复杂语法。 为了便于访问,我们将在此处列出Microsoft提供的所有详细信息。

操作和语法 (Operation and Syntax)

OperationSyntax
AddREG ADD <KeyName> [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]
CompareREG COMPARE <KeyName1> <KeyName2> [{/v ValueName | /ve}] [{/oa | /od | /os | on}] [/s]
CopyREG COPY <KeyName1> <KeyName2> [/s] [/f]
DeleteREG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]
Export

REG EXPORT KeyName FileName [/y]

ImportREG IMPORT FileName
Load

REG LOAD KeyName FileName

Query

REG QUERY <KeyName> [{/v <ValueName> | /ve}] [/s] [/se <Separator>] [/f <Data>] [{/k | /d}] [/c] [/e] [/t <Type>] [/z]

Restore

REG RESTORE <KeyName> <FileName>

Save

REG SAVE <KeyName> <FileName> [/y]

Unload

REG UNLOAD <KeyName>

操作方式 句法
REG添加<KeyName> [{/ v ValueName | / ve}] [/ t数据类型] [/ s分隔符] [/ d数据] [/ f]
比较 REG COMPARE <KeyName1> <KeyName2> [{/ v ValueName | / ve}] [{/ oa | / od | / os | on}] [/ s]
复制 REG COPY <KeyName1> <KeyName2> [/ s] [/ f]
删除 REG DELETE <KeyName> [{/ v ValueName | / ve | / va}] [/ f]
出口

REG EXPORT键名文件名[/ y]

进口 REG导入文件名
加载

REG LOAD键名FileName

询问

REG QUERY <键名> [{/ v <值名> | / ve}] [/ s] [/ se <分隔符>] [/ f <数据>] [{/ k | / d}] [/ c] [/ e] [/ t <Type>] [/ z]

恢复

REG RESTORE <键名> <文件名>

保存

REG保存<键名> <文件名> [/ y]

卸下

REG卸载<KeyName>

参数及参数说明 (Parameter and Parameter Description)

ParameterDescription
<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: HKLM, HKCU, HKCR, HKU, and HKCC. 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 registry entry to be added under the specified subkey.
/veSpecifies that the registry entry that is added to the registry has a null value.
/t <Type>Specifies registry types to search. Valid types are: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, REG_NONE. If not specified, all types are searched.
/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 needs to be listed. If not specified, the default separator is \0.
/d <Data>Specifies the data for the new registry entry.
/fAdds the registry entry without prompting for confirmation.
/oa
Specifies that all differences and matches are displayed. By default, only the differences are listed.
/odSpecifies that only differences are displayed. This is the default behavior.
/osSpecifies that only matches are displayed. By default, only the differences are listed.
/onSpecifies that nothing is displayed. By default, only the differences are listed.
/sCompares all subkeys and entries recursively.
/vaDeletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted.
<FileName>Specifies the name and path of the file to be created during the operation. The file must have a .reg extension.
/yOverwrites any existing file with the name FileName without prompting for confirmation.
/se <Separator>Specifies the single value separator to search for in the value name type REG_MULTI_SZ. If Separator is not specified, \0 is used.
/f <Data>Specifies the data or pattern to search for. Use double quotes if a string contains spaces. If not specified, a wildcard (*) is used as the search pattern.
/kSpecifies to search in key names only.
/dSpecifies to search in data only.
/cSpecifies that the query is case sensitive. By default, queries are not case sensitive.
/eSpecifies to return only exact matches. By default, all the matches are returned.
/zSpecifies to include the numeric equivalent for the registry type in search results.
/?Displays help for reg <operation> at the command prompt.
参数 描述
<键名> 指定要添加的子项或条目的完整路径。 要指定远程计算机,请将计算机名称(格式为\\ <ComputerName>)作为KeyName的一部分。 省略\\ ComputerName \会使该操作默认为本地计算机。 KeyName必须包含有效的根密钥。 本地计算机的有效根密钥为:HKLM,HKCU,HKCR,HKU和HKCC。 如果指定了远程计算机,则有效的根密钥为:HKLM和HKU。 如果注册表项名称包含空格,请用引号引起来。
/ v <值名称> 指定要在指定子项下添加的注册表项的名称。
/ ve 指定添加到注册表的注册表项具有空值。
/ t <类型> 指定要搜索的注册表类型。 有效类型为:REG_SZ,REG_MULTI_SZ,REG_EXPAND_SZ,REG_DWORD,REG_BINARY,REG_NONE。 如果未指定,则搜索所有类型。
/ s <分隔符> 指定当指定REG_MULTI_SZ数据类型并且需要列出多个条目时,用于分隔多个数据实例的字符。 如果未指定,则默认分隔符为\ 0
/ d <数据> 指定新注册表项的数据。
/F 添加注册表项,而不提示您进行确认。
/ oa
指定显示所有差异和匹配项。 默认情况下,仅列出差异。
/ od 指定仅显示差异。 这是默认行为。
/ os 指定仅显示匹配项。 默认情况下,仅列出差异。
/上 指定不显示任何内容。 默认情况下,仅列出差异。
/秒 递归比较所有子项和条目。
/ va 删除指定子项下的所有条目。 指定子项下的子项不会被删除。
<文件名> 指定操作期间要创建的文件的名称和路径。 该文件必须具有.reg扩展名。
/ y 覆盖名称为FileName的任何现有文件,而不提示您进行确认。
/ se <分隔符> 在值名称类型REG_MULTI_SZ中指定要搜索的单个值分隔符。 如果未指定分隔符 ,则使用\ 0
/ f <数据> 指定要搜索的数据或模式。 如果字符串包含空格,请使用双引号引起来。 如果未指定,则使用通配符( * )作为搜索模式。
/ k 指定仅搜索键名。
/ d 指定仅搜索数据。
/C 指定查询区分大小写。 默认情况下,查询不区分大小写。
/ e 指定仅返回完全匹配项。 默认情况下,将返回所有匹配项。
/ z 指定在搜索结果中包括注册表类型的等效数字。
/? 在命令提示符下显示reg <operation>的帮助。

翻译自: https://www.howtogeek.com/677453/how-to-edit-the-windows-registry-from-the-command-prompt/

注册表关闭命令提示符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值