Click here to Skip to main content
14,930,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was writing code in 32 bit exe, when i making the connection to powershell default its connecting to 32 bit powershell.

but i need to connect to 64 bit powershell.

how to achieve that.

Runspace runspace = RunspaceFactory.CreateRunspace();

Pipeline pipeline = runspace.CreatePipeline();

like this i am creating the pipeline.
Updated 26-Apr-17 20:13pm

As far as I know, this isn't possible unless you create an extra x64 application (console, for instance) to call powershell.

Note a similar situation here[^]
Using a Runspace, it's not possible. You cannot mix 32- and 64-bit code in the same process. You'd have to talk to a 64-bit PowerShell script running as a separate process and use some interprocess communication methods to pass commands and data back and forth, such as named pipes. Of course, the PowerShell script would have to be specially written to support this.

The solution to this problem is very simple.
We have copied copied 64 bit console PowerShell.exe to debug folder of the current VisualStudio Project and provided the same path (.\debug RR .\\debug) to trigger the powershell script, and it works fine.

Abhimanyu Panwar

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900