0

Consider the following powershell script:

[System.IntPtr]::Size
[Environment]::Is64BitProcess

If I run this directly inside powershell on a 64bit machine, then I correctly get

8
True

But when I wrap this inside a self-extracting installer using Inno Setup (that is built on a 32bit machine) I always get:

4
False

How do I make sure powershell is running in 64bit mode when on a 64bit computer (and 32bit for 32bit computer)?

I have also tried executing a batch file which calls the powershell script, assuming that the system would start powershell in its default mode, but this also doesn't work.

I have also tried iexpress to wrap the program, same problem.

timyhac
  • 133
  • 1
  • 5

1 Answers1

0

If your installer is a 32bit Application, it will always start a 32bit PowerShell. Even using the full path:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

because the Windows File system redirector will change it to C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe

to start a 64bit PowerShell from a 32bit process, use:

C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe

on a 32bit machine, the same command should still execute the 32bit PowerShell, but I can't test that anymore.