我怎样才能在一个特定的位置打开一个cmd窗口,而不必一直导航到我想要的目录?
当前回答
我刚刚看到这个问题,无法帮助发布我的自动热键脚本在Windows XP上的cmd。您可以在脚本中找到热键。好的事情是,当你当前的窗口是资源管理器时,cmd将在地址栏显示的路径中打开。
我把这个脚本保存在存放所有绿色工具(包括自动热键)的文件夹中。对于一台新机器,我只需复制文件夹,双击脚本将.ahk与AutoHotkey关联起来,并在启动文件夹中创建一个快捷方式。它比安装PowerToys还要快。
; Get working folder
GetWorkingFolder() {
if WinActive("ahk_class ExploreWClass") or WinActive("ahk_class CabinetWClass") {
ControlGetText, path, Edit1
return %path%
} else if WinActive("FreeCommander") {
Send, {CTRLDOWN}{ALTDOWN}{INS}{ALTUP}{CTRLUP}
Sleep, 100
return clipboard
} else {
return "C:\"
}
}
#IfWinActive,
#c::
path := GetWorkingFolder()
Run, %ComSpec%, %path%
return
; PowerShell
#+C::
path := GetWorkingFolder()
Run, %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe, %path%
return
#^c::
Run, %ComSpec%, %temp%
return
#!c::
path := GetWorkingFolder()
Run, %comspec% /k "%VS90COMNTOOLS%vsvars32.bat", %path%
return
; irb
#!b::
path := GetWorkingFolder()
Run, c:\cygwin\bin\ruby /usr/bin/irb, %path%
return
; Bash
#b::
path := GetWorkingFolder()
Run, bash --login, %path%
return
; Paste in console
+INS::
if WinActive("ahk_class ConsoleWindowClass") {
WinGetPos, x, y, w, h, A
MouseGetPos, mx, my
;MsgBox x=%x% y=%y% w=%w% h=%h% mx=%mx% my=%my%
if (mx < 10)
mx = 10
else if (mx > w - 30)
mx := w - 30
if (my < 40)
my = 40
else if (my > h)
my := h - 10
MouseClick, right, mx, my
}
return
对于任何感兴趣的人,你可以在github上的rwin上找到这个脚本
其他回答
如果您使用的是Windows Vista或更高版本,请按住Shift键右键单击资源管理器中的文件夹图标,然后单击“在此打开命令窗口”或“在此打开PowerShell窗口”上下文菜单选项。
如果你已经在你想要的文件夹中,你可以执行以下操作之一:
[only Win8+] Click the Explorer Ribbon's File button, then click on "Open command window here" or "Open PowerShell window here". Shift-right-click on the background of the Explorer window, then click on "Open command window here" or "Open PowerShell window here". (recommended by Kate in the comments) [only Vista or Win7] Hold down Shift when opening the Explorer File menu, then click on "Open command window here". If you can't see the menu bar, open the File menu by pressing Alt-Shift-F - Alt-F to open the File menu, plus Shift.
对于Windows XP,使用dF提到的PowerToy来获得相同的功能。
如果你从任务栏启动cmd,这是你需要做的:
在命令提示符上右键单击——>——>属性
然后在属性窗口中更改Start in的值:
此解决方案不适用于以管理员身份打开命令提示符
如果你使用全面指挥官,在底部有一个字段。它显示您当前所在的活动目录,并将在该目录中运行输入的命令。
Windows 10文件资源管理器现在有一个“快速访问工具栏”。
只需按“Alt+F”打开文件菜单,导航到“打开Windows PowerShell”菜单,右键单击并选择“添加到快速访问工具栏”:
现在你会看到一个你可以点击的小图标,它会在你所在的目录下打开PowerShell:
更新:这是内置在Windows现在。请看这个答案。
XP的动力玩具是一个不错的选择,但我想我要发布另一个,以防你想“滚你自己的”。创建一个文本文件,命名为任何。Reg,粘贴下面的代码,保存它,然后双击它将其添加到注册表中(或者只要手动将信息添加到注册表中,如果您了解这个. Reg文件中发生了什么)。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...]
@="Command Prompt Here..."
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...\command]
@="cmd.exe \"%1\""
更新:在windows更新后,Win10删除了cmd-here功能。要重新激活它,你必须使用:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="@shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /s /k pushd \"%V\""
ShowBasedOnVelocityId为必选项
推荐文章
- GIT克隆在windows中跨本地文件系统回购
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 为什么这个Windows批处理文件只执行第一行,而在命令shell中执行所有三行?
- 环境变量存储在Windows注册表的哪里?
- 有一个好的Valgrind Windows的替代品吗?
- Windows和Linux上的c++编译:ifdef开关
- 如何验证批处理文件中是否存在一个文件?
- 异步运行Windows批处理文件命令
- XAMPP -端口80被PID 4的“无法打开进程”使用!12
- 为什么git在Windows下记不住我的密码
- Git克隆/拉不断冻结在“存储密钥在缓存?”
- 有没有替换Windows (Visual C)的unistd.h ?
- 从Windows批处理文件设置系统环境变量?
- 在Sublime Text 2中使用Ctrl+D进行多个选择时,我如何跳过匹配?