In my app installer (InnoSetup), I need to run some powershell scripts.
Here is the code in Pascal:
Exec('cmd', '/C powershell -F .\MyScript.ps1 -ExecutionPolicy Unrestricted', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Basically, it runs in a command prompt the following command:
powershell -F .\MyScript.ps1 -ExecutionPolicy Unrestricted
The problem is that I get the following error:
MyScript.ps1 cannot be loaded because the execution of scripts is disabled on this system.
I know I can fix it by manually setting the ExecutionPolicy before running my script but my understanding of the -ExecutionPolicy
argument is that it "overrides" the execution policy during the execution of the script. My goal when positioning this argument is to handle all cases, since I cannot predict the execution policy of the computer that will install my app.
Some additional information:
- the installer is run as administrator
- it looks like inno setup run in x86 mode
- the execution policy of the computer I test the installer on is set to
Restricted
(in both x86 and x64)