当创建一个Windows快捷方式启动一个PowerShell
脚本以下工作正常双时,作为一个普通用户,并用鼠标右键单击Run as administrator
点击:Windows快捷方式与相对路径PowerShell脚本
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -Command "&{& 'C:\Script.ps1'}"
但是,当路径是相对的并且不知道前面的情况时,以下情况在正常用户双击时可以正常工作,但不能右键单击Run as administrator
:
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -Command "&{& '.\Script.ps1'}"
我的问题,我怎么能在两种情况下工作,当路径是相对的?我试过使用PSScriptRoot
,但那也没用。
谢谢你的帮助。
相对于什么?屏幕截图中的“开始”框为空。你是填满那个盒子,还是有一些其他的路径用于开始? –
这是我对这个问题的解决方案:http://stackoverflow.com/a/35054677/368889 – Mica