繁体   English   中英

Powershell:使用x86 powershell / ise运行的脚本

[英]Powershell: Script to run with x86 powershell/ise

我创建的脚本使用只有32位版本的PowerShell才能使用的组件。

默认情况下,windows使用powershell x64来处理脚本,并导致多个错误。

是一种在脚本开头设置值以强制Windows使用powershellx86而不是x64的方法吗?

例:

using powershell(x86).exe

scriptblock

谢谢

难道你不能只启动“powershell(x86).exe”文件?

的%SystemRoot%\\ SysWow64资料\\ WindowsPowerShell \\ V1.0 \\ powershell.exe

/弗雷德里克

没有简单的方法可以做到这一点,但有一种方法可以在x64主机中调用另一个Powershell主机实例,该实例也可能是x86。 $ env:PROCESSOR_ARCHITECTURE将告诉您正在运行的Powershell主机版本。

只是草图,用凿子和砂纸完成。

function Execute-Scriptx86
{
    param(
    [Parameter(Mandatory=$True,Position=1)]
    [string]$ScriptFile
    )

    if($env:PROCESSOR_ARCHITECTURE -eq "AMD64")
    {
        $powershellx86 = $env:SystemRoot + "\syswow64\WindowsPowerShell\v1.0\powershell.exe"
        & $powershellx86 -File $ScriptFile
    }
    else
    {
        & $ScriptFile
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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