有没有办法从Windows资源管理器启动PowerShell在一个特定的文件夹,例如右键单击一个文件夹,并有一个选项,如“打开PowerShell在这个文件夹”?
每天我第一次运行MSBuild时,都要更改项目文件夹的目录,这真的很烦人。
有没有办法从Windows资源管理器启动PowerShell在一个特定的文件夹,例如右键单击一个文件夹,并有一个选项,如“打开PowerShell在这个文件夹”?
每天我第一次运行MSBuild时,都要更改项目文件夹的目录,这真的很烦人。
当前回答
在Windows 10中,命令提示符和powershell提示符都可以通过菜单栏找到,无论是非管理员用户还是管理员用户。这些选项将其文件夹设置为当前从资源管理器中选择的文件夹。
至少对于瑞典版本,powershell是用Alt F+I打开的。对于管理员powershell,它是Alt F+S+P。
如果这些不是正确的字符,您可以按住Alt键查看正确的字符。每个步骤的菜单项上将覆盖一个字符。
其他回答
只是添加一个反向的技巧,在PowerShell提示符下你可以这样做:
ii .
or
start .
在当前目录中打开Windows资源管理器窗口。
只有在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'"
我很惊讶没有人给出这个答案,这是最简单的答案。(一定是那年。)
只需在资源管理器中Shift +右键单击。然后你可以在这里打开PowerShell窗口。
默认情况下可以设置为命令提示符。如果是这样,你可以在Windows 10设置中进行更改:转到个性化->任务栏,启用“当我右键单击开始按钮或按Windows键+X时,将菜单中的命令提示符替换为Windows PowerShell”。
有一个Windows资源管理器扩展是由一个为SVN制作工具的家伙做的,它至少会打开一个命令提示窗口。
我还没有尝试过,所以我不知道它是否能做PowerShell,但我想与Stack Overflow的兄弟们分享我的爱:
http://tools.tortoisesvn.net/StExBar
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的详细脚本