How to determine OS Platform with WMI?

后端 未结 13 3575
無奈伤痛
無奈伤痛 2021-02-20 03:46

I am trying to figure out if there is a location in WMI that will return the OS Architecture (i.e. 32-bit or 64-bit) that will work across \"all\" versions of Windows. I though

13条回答
  •  情歌与酒
    2021-02-20 04:41

    If you need the Operating System architecture as opposed to the processor, this works if you're confident you have no 64 bit Windows 5.x systems:

    Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)  
    on error resume next  
    
    For Each objItem in colItems  
        Ver = objItem.Version  
        OSname = split(objItem.Name,"|")  
        Arch = "32-bit"  
        if left(Ver,3) >= 6.0 then    ' 5.x doesn't support this property  
            Arch = objItem.OSArchitecture  
        end if  
    Next  
    wscript.echo " OS Version: " & Ver & " {" & trim(OSname(0)) & " " & Arch & "}"
    

提交回复
热议问题