我怎样才能在一个特定的位置打开一个cmd窗口,而不必一直导航到我想要的目录?


当前回答

该方法使用cmd.exe和发送快捷方式,使cmd.exe可以直接打开目录。这种替代方法是在没有打开命令窗口在这里右键单击菜单。

打开“文件资源管理器”,在位置栏中输入shell:sendto,导航到“发送到文件夹”。 复制命令提示符快捷方式或创建一个新的快捷方式.lnk文件。 编辑快捷方式的属性,并将目标编辑为%windir%\system32\cmd.exe /k cd /d,然后按“OK”保存更改。 右键单击一个文件夹并展开“发送到菜单”以使用cmd快捷方式。

这个快捷方式应该打开一个cmd窗口,由右键单击选择的目录。

该方法至少在windows 7和10下有效。将快捷方式命名为命令提示符(cd)以指定快捷方式的任务。

可能的错误消息:

显示'目录名无效。'如果不是folder is 选中。 系统无法找到指定的驱动器。如果文件夹是 不存在。 文件名、目录名或卷标签语法不正确。如果选择了多个文件。

简单介绍一下快捷方式:在Send to下使用时,目录会作为参数自动添加到快捷方式的末尾,因此快捷方式不需要输入目录。

其他回答

尽管在Windows 10下的HKCR\Directory\shell有几个答案(不工作),但以下对我来说是有效的:

SetOpenCmdHere.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\cmd]
@="Open CMD here..."

[HKEY_CLASSES_ROOT\Folder\shell\cmd\command]
@="C:\\Windows\\system32\\cmd.exe /k pushd \"%1\""

该方法使用cmd.exe和发送快捷方式,使cmd.exe可以直接打开目录。这种替代方法是在没有打开命令窗口在这里右键单击菜单。

打开“文件资源管理器”,在位置栏中输入shell:sendto,导航到“发送到文件夹”。 复制命令提示符快捷方式或创建一个新的快捷方式.lnk文件。 编辑快捷方式的属性,并将目标编辑为%windir%\system32\cmd.exe /k cd /d,然后按“OK”保存更改。 右键单击一个文件夹并展开“发送到菜单”以使用cmd快捷方式。

这个快捷方式应该打开一个cmd窗口,由右键单击选择的目录。

该方法至少在windows 7和10下有效。将快捷方式命名为命令提示符(cd)以指定快捷方式的任务。

可能的错误消息:

显示'目录名无效。'如果不是folder is 选中。 系统无法找到指定的驱动器。如果文件夹是 不存在。 文件名、目录名或卷标签语法不正确。如果选择了多个文件。

简单介绍一下快捷方式:在Send to下使用时,目录会作为参数自动添加到快捷方式的末尾,因此快捷方式不需要输入目录。

这将向上下文菜单添加条目,以启动一个自动导航到您所单击目录的命令窗口。

用法:

Right-click a folder icon (or the empty background area inside an already open folder)
and click either "Open in Terminal" or "Open in Terminal (Admin)".

You can also right click files to execute them with a command window.
When the file is done running you are left with a command window that is navigated to the files directory.

Open_in_Terminal.reg

Windows Registry Editor Version 5.00

; Admin versions.

; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%1\"'\""

; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""

; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""

; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \\\"%W \\\" && \\\"%1\\\"'\""

; Non-Admin versions.

; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%1\""

; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%V\""

; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%V\""

; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow\command]
@="cmd.exe /k pushd \"%W\" && \"%1\""

这需要很多努力,所以如果你觉得慷慨,然后随时发送一个贝宝捐赠,以帮助我克服调试和测试的创伤后应激障碍:)

一个卸载程序,如果你需要:

Open_in_Terminal_Remover.reg

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]

为什么这么多的设置,对于这个简单的事情,当你在路径在cmd输入

start .

并按Enter

试试微软的这个“强力玩具”吧:

此处打开命令窗口 这个PowerToy增加了一个“打开命令” “窗口此处”上下文菜单选项打开 文件系统文件夹,给你一个 快速打开命令窗口的方法 (cmd.exe)指向所选的 文件夹中。

编辑:此软件将不能工作在任何版本的Windows除了Windows XP。