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


当前回答

在Windows下到特定的文件夹,然后单击文件资源管理器路径并删除它,然后键入cmd并单击enter..在CMD中,您的特定文件夹及其路径将打开..

其他回答

创建一个快捷方式,并编辑快捷方式的“Start In”属性到您想要cmd.exe启动的目录。

而不是把它保存成一个快捷方式,这就是我的做法,我发现它非常有用。已经有答案可以作为快捷方式显示了,但我只是想分享这个,尤其是我发现它对angular项目非常有用。

创建一个新的txt文件 然后把下面的代码写进去。 @ECHO掉 cd C: \ YourProjectPath \ FolderPath \ 另存为。bat文件,取一个方便的名字。(我通常把它存为 “goto-myProjectName.bat” 然后将该bat文件复制到默认路径(当您运行cmd, 不管你的默认路径是什么,它都从它开始。例如,在 我的电脑是windows/system32。 然后输入bat文件的名称,去掉扩展名。 例如:goto-myProjectName

那它应该会带你去那里。

右键单击桌面,导航到新建,然后从子菜单中选择“快捷方式”→浏览到Windows目录(或文件夹),然后浏览到system32目录,单击确定。

在命令字符串中添加\和"cmd.exe"(不带引号)。它应该是这样的:

C:\WINDOWS\System32\cmd.exe.

单击下一步并完成。右键单击桌面上的新CMD图标,选择属性,然后单击“开始”旁边。在选项中,删除该行,并将路径添加到您想要它开始的目录…例如,输入C:\temp\mp3,然后单击“确定”。

使用/K开关。例如

cmd /K "cd /d c:\WINDOWS\"

将创建一个cmd窗口在C:\Windows目录

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

用法:

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]