What version of PowerShell on target machine does InstallShield use?

0

I have an installer (suite + MSI package) for a 32-bit application that is created using InstallShield 2015.

One of the custom actions that is executed (during the OnBegin event in the Suite) is a PowerShell script.
In the PS script, I'm attempting to load/interact with a C++ DLL (32-bit) by using Add-Type and DllImport (using this idea) (the $fullPathEscaped variable is resolved to a full path where the DLL is located during the installation, i.e., C:\Temp\{Blah}\Reg.DLL):

35   try
36   {
37    $MethodDefinition = @"
38    [DllImport("$($fullPathEscaped)", CharSet = CharSet.None)]
39    public static extern int Validate(string regPath);
40    "@
41    $Reg = Add-Type -MemberDefinition $MethodDefinition -Name 'ValidateInstall' -Namespace 'Reg' -PassThru
42    $result = $Reg::Validate($unlockCode)
43   }
44   catch
45   {
46    [System.Windows.Forms.MessageBox]::Show($_.Exception.Message , "Error")
47    exit(-1)
48   }

When I was attempting to execute this script directly using PowerShell ISE on my 64-bit Windows 10 machine, the engine would throw the following error when trying to call into the DLL / definition (on line 42):

Exception calling "Validate" with "1" argument(s): "An attempt was made to load a program with an incorrect format. (Exception from HRESULT 0x8007000B)"

Googling that error led me to trying to execute the script in 32-bit (x86) PowerShell.
Voila, it worked fine.

When the same script gets executed during the InstallShield Installer (on the same 64-bit machine), the script executes without any issues.

This leads me to believe that InstallShield is using the 32-bit version of PowerShell (for this particular install suite? Always?). However, I cannot find in InstallShield documentation or doing other searches on the web if that is a safe assumption or if it's something that happens to work "now" but is not a guarantee (i.e., if the it's something related to the current system or environment used to create and/or build the Installer).

What determines the version of PowerShell that will be used by InstallShield on a target machine?
Is it the architecture of the program being installed?
Or does InstallShield default to using 32-bit PowerShell?

I did verify that both PowerShell ISE and PowerShell (64-bit) encounter the error, just to eliminate some anomaly with using one or the other (since InstallShield would not use the ISE).
And I couldn't gather much from the DebugLog created when running the setup.exe file on my machine (excerpt from the log that I think is pertinent):

1-30-2018[02:48:53 PM]: Running event 'UnlockInstaller'
1-30-2018[02:48:53 PM]: Engine: request for proxy handler, 0, 0
1-30-2018[02:48:55 PM]: (PowerShell Action): Attempting to load through CLR 4 APIs...
1-30-2018[02:48:55 PM]: (PowerShell Action): Getting meta host...
1-30-2018[02:48:55 PM]: (PowerShell Action): Enumerating available runtimes...
1-30-2018[02:48:55 PM]: (PowerShell Action): Highest available runtime: v4.0.30319
1-30-2018[02:48:55 PM]: (PowerShell Action): Trying to use highest runtime...
1-30-2018[02:48:55 PM]: (PowerShell Action): Using highest version runtime...
powershell
32bit-64bit
installshield
asked on Stack Overflow Jan 30, 2018 by Gregg L

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0