In test.ps1: Remove-Item -Path "E:\temp\123.txt" -Force -ErrorAction Continue
In example.iss:
#define path "..\functions\test.ps1"
;#define path "E:\source\functions\test.ps1"
[Code]
var
ResultCode : Integer;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
Exec('cmd', '/C powershell.exe -ExecutionPolicy bypass -File "{#path}"', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
end
The example.iss file is in E:\source\installer. The powershell task is simple, which works fine in command line with both full path and the relative path. However in Inno setup, only the full path works (123.txt gets removed). It didn't work with the relative path.
I tried to place test.ps1 in the current folder with .\test.ps1, it didn't work either. The output folder(where the install exe was) was also tried, no luck as well.
Why it only works with the full path E:\source\functions\test.ps1?