有没有办法从Windows资源管理器启动PowerShell在一个特定的文件夹,例如右键单击一个文件夹,并有一个选项,如“打开PowerShell在这个文件夹”?

每天我第一次运行MSBuild时,都要更改项目文件夹的目录,这真的很烦人。


当前回答

在最新版本的Windows 10中,当你用鼠标Shift+右键点击空白区域时,默认在上下文菜单中有“在此打开PowerShell窗口”,现在你应该已经在使用Windows终端了。

其他回答

尝试PowerShell PowerToy…它为Open PowerShell Here添加了一个上下文菜单项。

或者您可以创建一个快捷方式,打开PowerShell的开始文件夹是您的项目文件夹。

在最新版本的Windows 10中,当你用鼠标Shift+右键点击空白区域时,默认在上下文菜单中有“在此打开PowerShell窗口”,现在你应该已经在使用Windows终端了。

通过添加下面的注册表键,在Windows 10中,我成功地在我的SHIFT + RClick上下文菜单中获得了Open PowerShell Here选项。 只需将这些复制到一个空白的记事本文件中,然后保存为.reg文件,并运行该文件来添加密钥,它应该从那里开始工作。 其中一些其他答案说,将密钥添加到HKCR\Directory\shell,但我发现,对我来说,它只适用于进入HKLM\SOFTWARE\Classes\Directory\shell的密钥

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell]
"Extended"=""
"NoWorkingDirectory"=""
@="Open PowerShell here"
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell]
@="Open PowerShell here"
"Extended"=""
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
"NoWorkingDirectory"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"

您可以从这里下载inf文件-介绍PowerShell提示在这里

在Windows 8.1和Server 2012 R2中更容易。

这样做一次: 右键单击任务栏,选择“属性”。在导航选项卡中,当我右键单击左下角或按Windows键+X时,打开菜单中的[✓]将命令提示符替换为Windows PowerShell。

然后当你想要PowerShell提示时,点击Win+X, i(或Win+X, a表示Admin PowerShell提示)