Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Powershell x86 within Visual Studio Code x64?

I've got a situation where I am using the 64-bit version of Visual Studio Code to write/debug a powershell script. However, because of what the Powershell script is doing it needs to run within the 32-bit version of Powershell. It's using some libs to access an MS Access file, so I have yet to find a way to make things work within Powershell x64.

Is there a way to tell VS Code to run the 32-bit version of Powershell if VS Code itself is running as 64-bit? For example, can I modify the launch.json file to specify the path of powershell itself?

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "PowerShell",
            "request": "launch",
            "name": "PowerShell Launch Current File",
            "script": "${file}",
            "args": [],
            "cwd": "${file}"
        },
        ...
     ]
}
like image 465
Sam Storie Avatar asked Sep 18 '17 11:09

Sam Storie


2 Answers

I found another method that's easier and seems to be provided by VSCode (although it might be an extension I added). In the main window there's a clickable element in the right side of the toolbar:

enter image description here

When you click that a menu appears near the top of the window with some powershell related options, including the ability to switch between x86 and x64:

enter image description here

like image 74
Sam Storie Avatar answered Oct 16 '22 03:10

Sam Storie


Assuming you have the PowerShell extension installed, you should be able to modify the powershell.powerShellExePath setting in VS Code Settings to "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe".

I believe you can also set "powershell.useX86Host": true. This was introduced in the PowerShell extension v0.5.0; I'm not sure how I missed it's inclusion!

However, it might be easier or better to install the 64-bit MS Access components and just use the 64-bit version.

Microsoft Access Database Engine 2010 Redistributable

Microsoft Access 2013 Runtime

Microsoft Access Database Engine 2016 Redistributable

I've no idea why the 2013 version has a different name, but as far as I can tell those are the same components for the different versions.

like image 23
Bacon Bits Avatar answered Oct 16 '22 04:10

Bacon Bits