Page 1 of 1

Running Powershell 64bit

Posted: Tue Nov 19, 2024 12:52 pm
by Paul Geary
Hi, I'm really hopeful that this is an easy question, but it has been driving me nuts for days:

I need to run a PowerShell script using the 64bit version of powershell.exe

Even if I explicitly run the program from the folder location:
c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe

My installer appears to use the 32 bit version. I check for the PS version in my script, using the command :
if([IntPtr]::size -eq 8 ) { Write-Host 'x64' } else { Write-Host 'x86' }

It returns 'x86' when run from the installer and 'x64' when run from the command line.

I have added the following command as the first line of my install code but it seems to make no difference:
Set x64 - Native 64 bit Windows, AMD64, EM64T, and ARM64 Architectures - installation mode

Please advise,

Thank you,

Paul

Re: Running Powershell 64bit

Posted: Wed Nov 20, 2024 7:58 am
by JohnGaver
This topic applies to InstallAware Multi Platform as well.

You're using the wrong folder (that is the 32-bit folder).

Set 64 bit mode before calling Run Program, and invoke from the system32 folder (yes, crazy but that is the 64-bit folder).

If you don't set 64 bit mode before the call, the OS itself will automagically redirect your call to the 32 bit folder again (that you are actually presently referencing anyways).

Re: Running Powershell 64bit

Posted: Fri Nov 22, 2024 8:41 am
by Paul Geary
Great advice, now working.

Thanks for your help.

Paul