如何检查 wscript/cscript 是否在 x64 主机操作系统上运行? [英] How do I check if wscript/cscript runs on x64 host OS?

查看:30
本文介绍了如何检查 wscript/cscript 是否在 x64 主机操作系统上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm running a VBScript that may run under x64 Windows. I need to read a registry key from the 32-bit part of the registry. For that I use path HKLMSoftwareWow6432Nodexyz instead of HKLMSoftwarexyz. How can I check if the script is executed under x64?

推荐答案

我不确定您是否需要检查脚本是否在 x64 下执行.

I'm not sure you need to check if the script is executing under x64.

尝试从 HKLMSoftwareWow6432Nodexyz 读取,如果失败,尝试从 HKLMSoftwarexyz 读取,如果失败,你的注册表项不存在,采取任何适当的行动.

Try to read from HKLMSoftwareWow6432Nodexyz, if that fails, try to read from HKLMSoftwarexyz, if that fails, your registry key doesn't exist, take whatever action is appropriate.

当然,如果您的设计更复杂(例如,如果该注册表项不存在,您将其写入一个值),那么该建议将不起作用.

Of course, if your design is more complicated (for example, you write a value into that registry key if it doesn't exist) then that suggestion won't work.

这是用于检查操作系统的 VBScript.您可能还需要对 属性的解释Win32_操作系统类

Here is a VBScript for examining the operating system. You'll probably also need explanation of the Properties available from the Win32_OperatingSystem Class

strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "
ootcimv2")        

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    msg = objOperatingSystem.Caption & " " & _
            objOperatingSystem.Version & " " & _
                objOperatingSystem.OSArchitecture
    msgbox msg
Next

请注意,对于 Windows XP 和 2003,OSArchitecture 不可用,在这种情况下,您可能需要检查 CaptionVersion 确定您的操作系统是否为 64 位.

Note that for Windows XP and 2003, OSArchitecture is not available, in which case you will probably have to examine either the Caption or Version to determine whether your OS is 64-bit.

您也可以使用this取决于您需要的复杂程度.

You could also use something like this depending on the level of complexity you require.

这篇关于如何检查 wscript/cscript 是否在 x64 主机操作系统上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆