从快捷方式打开特定目录中的Powershell
这听起来应该是这么简单…我一定是愚蠢的。
我只想做一个窗口快捷方式,将Powershell打开到一个特定的目录中:
我正在使用目标:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command {cd c:/path/to/open} 把它只是作为文本吐出命令。
任何帮助,将不胜感激。
 或者使用: powershell.exe -noexit -command "cd c:\temp " 
您还可以将“开始”(Start in)快捷方式字段设置为所需的位置。
尝试:
 %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd c:/path/to/open" 
将此代码复制到记事本中,并使用reg扩展名保存。 双击生成的文件。如果您收到有关导入registry的消息,请单击是,然后确定。 导航到资源pipe理器中的任何文件夹,并调出上下文菜单。 这通常是通过点击鼠标右键来完成的。
 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\PShell] "MUIVerb"="Open in Powershell Window" [HKEY_CLASSES_ROOT\Directory\Background\shell\PShell\command] @="c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'" 
 好的 – 你需要使用&参数来指定它是一个powershell命令,语法略有不同: 
 %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "& {cd c:\path\to\open}" 
 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资源pipe理器启动PowerShell下载详细脚本
  
 
 如果你想让powershell作为pipe理员启动并运行在特定的目录下,即使在不同的驱动器上,最好使用Set-Location命令。 按着这些次序 
- 创build一个目标是powershellcommand exe的ShortCutLink。
-  保留Start in:空白。 ( 通常这从当前的工作目录开始,但是我们不在意)。
- 
将 Target更改为PowerShell和位置的目标:C:\Windows\...\v1.0\powershell.exe -noexit -command "Set-Location D:\_DCode\Main"
-  单击Advanced...并selectRun as administrator。
-  点击OK。
 不要忘记从“ Colors选项卡更改快捷键颜色的便捷技巧。 这样,如果你有两个或更多的链接打开PowerShell的窗口,看到不同的颜色可以在视觉上让你知道哪个shell正在工作。