如何在Visual Studio Code x64中运行Powershell x86?

Sam*_*rie 5 powershell visual-studio-code

我有一种情况,我使用64位版本的Visual Studio代码来编写/调试powershell脚本.但是,由于Powershell脚本正在做什么,它需要在32位版本的Powershell中运行.它使用一些库来访问MS Access文件,所以我还没有找到一种方法让Powershell x64中的东西工作.

如果VS Code本身作为64位运行,有没有办法告诉VS Code运行32位版本的Powershell?例如,我可以修改launch.json文件以指定powershell本身的路径吗?

{
    // 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}"
        },
        ...
     ]
}
Run Code Online (Sandbox Code Playgroud)

Sam*_*rie 10

我发现另一种方法更容易,似乎是由VSCode提供的(尽管它可能是我添加的扩展).在主窗口中,工具栏右侧有一个可点击元素:

在此输入图像描述

当您单击窗口顶部附近的菜单时,会显示一些与PowerShell相关的选项,包括在x86和x64之间切换的功能:

在此输入图像描述

  • +1我唯一的扩展是PowerShell和图标扩展,所以我愿意相信它是PowerShell扩展本身的一部分. (2认同)

Bac*_*its 4

假设您安装了PowerShell 扩展,您应该能够将powershell.powerShellExePathVS Code 设置中的设置修改为"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe".

相信你也可以设定"powershell.useX86Host": true。这是在 PowerShell 扩展 v0.5.0 中引入的;我不知道我是如何错过它的包含!

但是,安装 64 位 MS Access 组件并仅使用 64 位版本可能会更容易或更好。

Microsoft Access 数据库引擎 2010 可再发行组件

Microsoft Access 2013 运行时

Microsoft Access 数据库引擎 2016 可再发行版

我不知道为什么 2013 版本有不同的名称,但据我所知,不同版本的组件是相同的。