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
In VBS:
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "AddressWidth: " & objItem.AddressWidth
Next
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"
To expand on the first answer, use this:
select AddressWidth from Win32_Processor where DeviceID="CPU0"
Use the following WMI class and property - This should work on 2003/XP and Win7/2008R2
ROOT\CIMV2\Win32_Processor
AddressWidth
From Technet:
On a 32-bit operating system, the value is 32 and on a 64-bit operating system it is 64. This property is inherited from CIM_Processor.
I know this is old, I am posting this for anyone in the future. Try looking at my script. It's written in BATCH and uses WMIC if it is on the computer but does not need it in order to determine whether the OS is running a 32 bit of 64 bit OS.
Try this:
wmic cpu get DataWidth /format:list