命令提示符(Command Prompt)是执行某些任务的一种非常有用的方法。例如,如果您想运行带有特殊参数的程序,命令提示符(Command Prompt)是一种快速的方法。问题是在使用命令提示符(Command Prompt)时导航现代计算机的目录结构可能会很痛苦。特别是因为Windows 10支持如此长的文件夹和程序名称。
好消息是您可以直接从Windows 资源管理器(Windows Explorer)窗口中打开命令提示符。(Command Prompt)直接带您到该文件夹位置!
命令提示符与 PowerShell
关于在文件夹中打开命令提示符的重要一点是,我们专门指的是Windows 命令提示符(Windows Command Prompt),而不是PowerShell。尽管这两个程序看起来很相似,都是文本命令界面,但它们实际上是非常不同的。
命令提示符是一个简单、轻量级的(Command Prompt)Windows文本界面。相比之下,PowerShell是一个复杂而强大的命令行工具,它可以让高级用户对计算机进行深入的系统管理,以及一长串其他方便的功能。
命令提示符(Command Prompt)使用“CMD.exe”,而PowerShell使用“powershell.exe”,因此它们是完全独立的。尽管某些功能重叠,但两个程序可能使用不同的命令来完成相同的工作。本文仅介绍命令提示符(Command Prompt),但某些快捷方式也适用于PowerShell。我们会在这种情况下指出。
使用资源管理器地址栏(Explorer Address Bar)打开命令提示符(Command Prompt)
当您打开Windows 资源管理器(Windows Explorer)文件夹时,您会看到一个类似于 Web 浏览器中的地址栏。默认情况下,它显示当前文件夹的路径。你可以在这里看到它。
如果单击此地址栏,则可以输入文本。通过键入“cmd”并按Enter,您将在该位置打开命令提示符。
如果您键入“powershell”而不是“cmd”,这也将起作用。将您直接带到该文件夹的Windows PowerShell提示符。
添加“在此处打开命令窗口”
在Windows 10的早期版本中,有一个名为“在此处打开命令窗口”的上下文菜单条目,它将在您指定的文件夹位置打开命令提示符(Command Prompt)。例如,如果您右键单击文件夹并使用此命令,则命令提示符(Command Prompt)将从当前文件夹位置开始。
在 2017 Creator's Update for Windows 10之后,Microsoft删除了此选项。为什么?这很可能是因为微软(Microsoft)努力推动人们从使用命令提示符(Command Prompt)转向使用PowerShell。
取回这个命令并不是很困难,但它确实需要在Windows 注册表(Windows Registry)中进行一些修改。如果您不喜欢这样做,最好跳过此方法,但如果您真的想要返回该上下文菜单选项,请执行以下操作。
首先,单击开始并键入regedit。然后单击regedit程序条目。
打开注册表编辑器,在此路径中查找以下注册表项:
HKEY_CLASSES_ROOT\Directory\shell\cmd
这是事情可能开始有点冒险的地方,但我们不会做任何会破坏您的计算机的事情。但请确保您遵循这些确切的说明!
右键单击(Right-click )该键,然后单击上下文菜单中的权限(Permissions )。
在打开的对话框中,单击高级。(Advanced.)
在高级设置窗口的顶部,您会看到列出的密钥所有者。单击更改( Change )选项。
接下来,输入您的用户名,然后单击检查名称(check names)以验证它。然后单击确定(OK)。
最后,确保在单击OK之前选中Replace owner on subcontainers and objects框。
现在我们回到权限页面。选择组或用户名下(Group or user names)的管理员(Administrators),然后选择完全控制(Full control)旁边的允许(Allow)。然后单击确定(OK)。
现在我们必须恢复Command Prompt的上下文菜单条目。
回到CMD窗口,我们要做的就是将“ DWORD ”从“ HideBasedOnVelocityiD ”更改为“ ShowBasedOnVelocityId ”。只需右键单击它并选择重命名,( rename,)然后更改 DWORD 的名称。
如果一切都按计划进行,您现在应该看到“在此处打开命令窗口”选项,当您 SHIFT+右键单击Windows 资源管理器(Windows Explorer)窗口中的项目时。
使用 Windows 资源管理器(Command Prompt Using Windows Explorer)打开命令提示符
从Windows 资源管理器窗口打开(Windows Explorer)命令提示符(Command Prompt)的下一种方法涉及导航到命令提示符(Command Prompt)程序本身的存储位置并直接从那里运行它。当由于某种原因,其他打开命令提示符(Command Prompt)的方法不起作用时,这仍然很有用。
您可以在 C:WindowsSystem32 中找到“cmd.exe”。如果您想以管理员权限运行它,只需右键单击 cmd.exe 并选择Run as administrator。有很多命令需要管理权限才能工作,这是您无需离开Explorer即可使用这些权限启动(Explorer)命令提示符(Command Prompt)的方法之一。
你现在在指挥!
正如他们对超级终端(HyperTerminal)所做的那样,微软(Microsoft)可能会选择有一天完全淘汰命令提示符(Command Prompt),转而支持PowerShell。虽然这本身并不是一件坏事,但PowerShell可以做一些改进,以帮助那些本来可以使用命令提示符(Command Prompt)的非高级用户同样轻松地使用常用功能。尽管如此,直到Command Prompt真正成为Dodo的那一天,您可以放心,只需单击几下即可。
如果您需要提高您的命令提示符(Command Prompt)技能,那么为什么不查看每个Windows用户都应该知道的这21 个命令。(21 commands)借助这些非常有用的技巧,您将立即完成任务。
Open Command Prompt in Folder Using Windows Explorer
The Command Prompt is an incredibly useful way to perform certain tasks. For example, if you want to run a program with special parameters, the Command Prompt is one fast way to do it. The problem is that navigating the directory structure of a modern computer can be a real pain when using Command Prompt. Especially since Windows 10 supports such long folder and program names.
The good news is that you can open Command Prompt directly from inside a Windows Explorer window. Taking you directly to that folder location!
Command Prompt vs PowerShell
One important point about opening the command prompt in a folder, is that we’re referring specifically to the Windows Command Prompt, rather than PowerShell. Although both programs look similar, being a text-command interface, they are actually very different.
Command Prompt is a simple, lightweight text interface for Windows. In contrast, PowerShell is a complex, powerful command line tool that lets power users do in-depth system management of the computer, among a long list of other handy abilities.
Command Prompt uses the “CMD.exe” while PowerShell uses “powershell.exe”, so they are entirely separate. Although some of the functionality overlaps, the two programs may use different commands to accomplish the same job. This article is only about the Command Prompt, but some of the shortcuts will also work for PowerShell. We’ll indicate when this is the case.
Open Command Prompt Using the Explorer Address Bar
When you open a Windows Explorer folder, you’ll see an address bar similar to that in a web browser. By default, it shows the path of the current folder. You can see it here.
If you click on this address bar, you can type in text. By typing “cmd” and hitting Enter, you’ll open up the command prompt at that location.
This will also work if you type “powershell” instead of “cmd”. Taking you directly to the Windows PowerShell prompt at that folder.
Adding “Open command window here”
In early versions of Windows 10, there was a context menu entry called “Open command window here” which would open the Command Prompt in the folder location you specify. For example, if you right-click on a folder and use this command, the Command Prompt starts at the current folder location.
After the 2017 Creator’s Update for Windows 10, Microsoft removed this option. Why? It’s most likely down to an effort from Microsoft to push people away from using the Command Prompt towards using PowerShell.
Getting this command back is not very difficult, but it does require some tinkering in the Windows Registry. If you don’t feel comfortable doing that, it’s best to skip this method, but if you really want that context menu option back, here’s what to do.
First, click Start and type regedit. Then click on the regedit program entry.
With the registry editor open, look for the following registry key at this path:
HKEY_CLASSES_ROOT\Directory\shell\cmd
This is where things might start to feel a little risky, but we aren’t doing anything that will break your computer. But make sure you follow these exact instructions!
Right-click on the key and click Permissions in the context menu.
In the dialogue box that opens up, click Advanced.
At the top of the advanced settings window, you’ll see the listed owner of the key. Click the Change option.
Next, type your username and then click check names to validate it. Then click OK.
Finally, make sure the Replace owner on subcontainers and objects box is selected before clicking OK.
Now we’re back on the permissions page. Select Administrators under Group or user names and select Allow next to Full control. Then click OK.
Now we have to restore the context menu entry for the Command Prompt.
Back inside the CMD window, all we have to do is change the “DWORD” from “HideBasedOnVelocityiD” to “ShowBasedOnVelocityId”. Just right-click on it and choose rename, then change the name of the DWORD.
If all has gone as planned, you should now see the “Open command window here” option, when you SHIFT+right-click an item in the Windows Explorer window.
Opening The Command Prompt Using Windows Explorer
This next method of opening the Command Prompt from a Windows Explorer window involves navigating to where the Command Prompt program itself is stored and running it directly from there. This is still useful when, for one reason or another, other means of opening Command Prompt don’t work.
You can find “cmd.exe” in C:\Windows\System32. If you want to run it with administrative privileges, simply right-click cmd.exe and choose Run as administrator. There are plenty of commands that require administrative privileges to work and this is one of the ways you can start the Command Prompt with those privileges without leaving Explorer.
You’re In Command Now!
As they;ve done with HyperTerminal, Microsoft may choose to one day completely phase out Command Prompt, in favor of PowerShell. While that’s not a bad thing in itself, PowerShell could do with some polish to help non-power users who would have been fine with the Command Prompt to use common functions just as easily. Still, until the day Command Prompt actually does go the way of the Dodo, you can rest assured it’s only a few clicks away.
If you need to improve your Command Prompt skills, then why not check out these 21 commands that every Windows user should know. You’ll be flying through tasks in no time armed with these incredibly useful tricks.