Windows Registry Editor Version 5.00
;
; Add context menu entry to Windows Explorer background
;
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
;
; Add context menu entry to Windows Explorer folders
;
[HKEY_CLASSES_ROOT\Directory\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
;
; Add context menu entry to Windows Explorer drive icons
;
[HKEY_CLASSES_ROOT\Drive\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
所以,用你最喜欢的文本编辑器,打开一个名为OpenPowerShellHere.reg的新文件。复制上面代码的< em >的< / em >文本,将其粘贴到新文件中,并保存。(我本想附上一份文件副本,但我不知道是否可以附上附件。)如果你想从其中一个条目中排除命令,只需用分号注释掉相应的部分。我的注释向您展示了每个部分。
; Ctrl-Alt-T opens PowerShell in the current folder, if using Windows Explorer. Otherwise, just open the Powershell.
^!T::
if WinActive("ahk_class CabinetWClass") and WinActive("ahk_exe explorer.exe")
{
KeyWait Control
KeyWait Alt
Send {Ctrl down}l{Ctrl up}
Send powershell{Enter}
}
else
{
psScript =
(
cd 'C:\<DefaultPath>'
ls
)
Run "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -NoExit -Command &{%psScript%}
}
return