How to determine OS Platform with WMI?

后端 未结 13 3333
無奈伤痛
無奈伤痛 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:30

    The simple WMI query that you used does indeed return a result for every physical CPU in the computer. It will only return one result if you have a single processor, multiple core CPU. We can safely assume the computer has atleast one CPU, so lets just use the information from CPU0.

    To select only 64-bit operating systems...

    select * from Win32_Processor where DeviceID="CPU0" and AddressWidth="64"
    

    To select only 32-bit operating systems...

    select * from Win32_Processor where DeviceID="CPU0" and AddressWidth="32"
    

提交回复
热议问题