有没有办法从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'"
其他回答
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
if(-not (Test-Path -Path "HKCR:\Directory\shell\$KeyName"))
{
Try
{
New-Item -itemType String "HKCR:\Directory\shell\$KeyName" -value "Open PowerShell in this Folder" -ErrorAction Stop
New-Item -itemType String "HKCR:\Directory\shell\$KeyName\command" -value "$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command Set-Location '%V'" -ErrorAction Stop
Write-Host "Successfully!"
}
Catch
{
Write-Error $_.Exception.Message
}
}
else
{
Write-Warning "The specified key name already exists. Type another name and try again."
}
您可以从Windows资源管理器中下载如何启动PowerShell的详细脚本
有一个Windows资源管理器扩展是由一个为SVN制作工具的家伙做的,它至少会打开一个命令提示窗口。
我还没有尝试过,所以我不知道它是否能做PowerShell,但我想与Stack Overflow的兄弟们分享我的爱:
http://tools.tortoisesvn.net/StExBar
只是添加一个反向的技巧,在PowerShell提示符下你可以这样做:
ii .
or
start .
在当前目录中打开Windows资源管理器窗口。
您可以从这里下载inf文件-介绍PowerShell提示在这里
在Windows资源管理器中,只需转到顶部的地址栏(键盘快捷键:Alt+D或Ctrl+L),输入powershell或powershell_ise并按Enter。将打开一个PowerShell命令窗口,其中包含当前目录。