I have a batch file that launches a PowerShell script with elevated privileges and bypasses execution policy:
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File ""C:\Users\Bob\Desktop\New folder\Server.ps1""' -Verb RunAs}";
This works Yea! I want to be able to use relative paths for the file path.
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File "".\Server.ps1""' -Verb RunAs}";
This fails for some reason. What am I doing wrong?
cd /d "%~dp0before the Powershell command to change to the correct folder.pushd C:\folderthen after the powershell commandpopd.