gpt4 book ai didi

vbscript - 如何检查 wscript/cscript 是否在 x64 主机操作系统上运行?

转载 作者:行者123 更新时间:2023-12-02 22:15:37 26 4
gpt4 key购买 nike

我正在运行一个可以在 x64 Windows 下运行的 VBScript。我需要从注册表的 32 位部分读取注册表项。为此,我使用路径 HKLM\Software\Wow6432Node\xyz 而不是 HKLM\Software\xyz。如何检查脚本是否在 x64 下执行?

最佳答案

即使在 64 位版本的 Windows 上,您的脚本也可以在 32 位模式下执行。

您可以使用以下代码来确定脚本运行的实际位模式:

option explicit

function Determine64BitMode
dim Shell, Is64BitOs
set Shell = CreateObject("WScript.Shell")
on error resume next
Shell.RegRead "HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir (x86)"
Is64BitOs = Err.Number = 0
on error goto 0
if Is64BitOs then
Determine64BitMode = InStr(Shell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir"), "(x86)") = 0
else
Determine64BitMode = false
end if
end function

dim ExecutingIn64BitMode
ExecutingIn64BitMode = Determine64BitMode
if ExecutingIn64BitMode then
MsgBox "64 bit"
else
MsgBox "32 bit"
end if

关于vbscript - 如何检查 wscript/cscript 是否在 x64 主机操作系统上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/556283/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com