有没有办法从Windows资源管理器启动PowerShell在一个特定的文件夹,例如右键单击一个文件夹,并有一个选项,如“打开PowerShell在这个文件夹”?
每天我第一次运行MSBuild时,都要更改项目文件夹的目录,这真的很烦人。
有没有办法从Windows资源管理器启动PowerShell在一个特定的文件夹,例如右键单击一个文件夹,并有一个选项,如“打开PowerShell在这个文件夹”?
每天我第一次运行MSBuild时,都要更改项目文件夹的目录,这真的很烦人。
当前回答
只有在Windows 10上我才用得到……
创建一个名为PowershellHereContextMenu的文件。reg与下面的内容,右键单击它,并“合并”。
Windows Registry Editor Version 5.00
;
; Add context menu entry to Windows Explorer folders
;
[HKEY_CLASSES_ROOT\Directory\shell\powershellmenu]
@="PowerShell Here"
[HKEY_CLASSES_ROOT\Directory\shell\powershellmenu\command]
@="C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
;
; Add context menu entry to Windows Explorer background
;
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershellmenu]
@="PowerShell Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershellmenu\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\powershellmenu]
@="PowerShell Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\powershellmenu\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
其他回答
尝试PowerShell PowerToy…它为Open PowerShell Here添加了一个上下文菜单项。
或者您可以创建一个快捷方式,打开PowerShell的开始文件夹是您的项目文件夹。
您可以从这里下载inf文件-介绍PowerShell提示在这里
您可以在Windows资源管理器地址栏上执行以下命令打开powershell,它将打开该目录的路径。
powershell.exe -noexit -command "Write-Host "Hello World"
要以管理员身份在文件资源管理器的任何位置运行PowerShell,请到该文件夹,并使用快捷方式“alt + f + s + a”以管理员身份在该特定文件夹位置打开PowerShell
Windows 10让这一切变得简单多了。你可以:
SHIFT +鼠标右键单击一个文件夹,你会得到一个菜单项打开PowerShell窗口。
或者你可以:
File ->打开Windows PowerShell。
作为奖励…
如果您鼠标右键单击文件>打开Windows PowerShell,那么您可以添加到快速访问工具栏:
这里有一个方便的图标:
现在你可以点击那个图标。:)