简体   繁体   中英

Running 32bit powershell on a 64bit server from c#

I was wondering if there is a way to stipulate which version of Powershell is initialised (32bit\64bit) on a 64bit windows 2008 server using c# and the the system.automation namespace?

The reason for this is I have created a ps1 script that uses a com object which will only work in a 32bit Powershell environment.

I am not aware of a way to specify 32bit\64bit during runspace creation but may be wrong. Any thoughts or suggestions?

Thanks

Changing your application's configuration from "Any CPU"/"x64" to "x86" is definitely the simplest way to make sure the Powershell script runs in 32-bit. You can check it with a script with these contents:

if ([System.IntPtr]::Size -eq 8) {'64-bit'} else {'32-bit'}

Configuring the Runspace to be 32-bit running in a 64-bit application may be possible, but it may also be more trouble than it's worth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM