When creating a Windows shortcut to run the PowerShell script, the following works fine if you double-click it as a regular user and right-click Run as administrator :
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -Command "&{& 'C:\Script.ps1'}"

However, when the path is relative and unknown in advance, the following works fine if you double-click it as a normal user, but without right-clicking Run as administrator :
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -Command "&{& '.\Script.ps1'}"
My question is, how can I make it work in both cases when the path is relative? I tried using PSScriptRoot , but that didn't work either.
Thank you for your help.
source share