I want to use PowerShell (64-bit version) in the ssPostInstall
step of my Inno Setup, but it always opens a 32-bit PowerShell.
As you can see in my script my Inno Setup is configured as 64-bit application. When I start the setup I can see in the Task Manager that it is running as a 32-bit application
Also the PowerShell which will be opened, is in 32 bit-mode.
Here is my Inno Stup script:
[Setup]
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
PrivilegesRequired=admin
[Code]
Procedure CurStepChanged(CurrentStep:TSetupStep);
var
i, ResultCode, ErrorCode: Integer;
findRec: TFindRec;
isInstallationCmdSuccessful: Boolean;
folderNameOfUpdateIni: String;
ReturnCode: Boolean;
begin
if CurrentStep = ssPostInstall then begin
Log('Starting post install steps, calling install.ps1');
ReturnCode := ShellExec('open', ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);
if (ReturnCode = True) then
Log('post install returned true')
else
Log('post install returned false');
Log('Starting post install steps, calling install.ps1');
ReturnCode := ShellExec('open', ExpandConstant('{syswow64}\WindowsPowerShell\v1.0\powershell.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);
if (ReturnCode = True) then
Log('post install returned true')
else
Log('post install returned false');
end;
end;
How can I force Inno Setup to open a 64-bit PowerShell?
If you want to allow Pascal Script code functions to use 64-bit System32
files, use EnableFsRedirection
function to disable WOW64 file system redirection.
And you also cannot use ShellExec
, you need to use Exec
function instead.
OldState := EnableFsRedirection(False);
try
ReturnCode :=
Exec('powershell.exe', '', '', SW_SHOWNORMAL, ewWaitUntilTerminated,
ErrorCode);
finally
EnableFsRedirection(OldState);
end;
Btw, ArchitecturesInstallIn64BitMode
does not/cannot make Inno Setup run as 64-bit application. Inno Setup is 32-bit application, no matter what.