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.

  • Your going about this problem the wrong way. Create two setups one 32-bit one 64-bit then dont worry about what platform since you will already know the platform – Ramhound Jun 17 '16 at 1:31
  • Have you tried checking the registry? According to this answer ( superuser.com/questions/290906/… ) you can check the value of "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLabEx" – Curtis Jun 17 '16 at 1:54
  • It may be more useful to check, if you still wish to be checking for this, in the registry as @Curtis mentioned. – root Jun 17 '16 at 17:16
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.