Skip to main content desktop

Determining OS Architecture

Shane CorellianShane Corellian

What is one of the problems you may encounter when a customer (or your boss) asks you to report how many computers have a 64 bit OS? One problem is that if you simply base the information on the CPU then you run the risk of getting false positives when a 32 bit OS is running on a 64 bit processor.What you want to look for is the Architecture type of the OS. Since a 64 bit OS cannot run on a 32 bit processor you know that if you identify the current OS type then you’ve accomplished your goal.

I prefer to look in WMI. One problem that you can run into is Windows versions prior to Vista. When looking at Windows XP and Windows 2003 you need to look in the Win32_ComputerSystem class. The property that I have found useful is SystemType. I extract the value from this property and apply a regular expression to extract the first three characters found. Here is a function in Visual Basic .NET that I use.

Dim OSArchitecture As Integer = 32
Dim objCS As New ManagementObjectSearcher(“SELECT * FROM Win32_ComputerSystem”)
For Each objMgmt As ManagementObject In objCS.Get
Dim TypeMatch As New Regex(“(x64)”)
Dim CSystemType As String= objMgmt(“SystemType”)).ToString
If TypeMatch.Match(CSystemType).Success Then
Return 64
End If

For Vista or later I use the Win32_OperatingSystem class and extract the value of the OSArchitecture property. I use a regular expression to match the first two digits encountered.

Dim objOS As New ManagementObjectSearcher(“SELECT * FROM Win32_OperatingSystem”)
Dim OSArchMatch As New Regex(“(^\d\d)”)
For Each objMgmt As ManagementObject In objOS.Get
If OSArchitecture = 32 Then
Dim OSArchitectureString As String = GetWmiValue(objMgmt, “OSArchitecture”).ToString
If Not OSArchitectureString = “” Then
If OSArchMatch.Match(OSArchitectureString).Success Then
OSArchitecture = AsInt(OSArchMatch.Group(0))
Return OSArchitecture
End If
End If
End If
Return 32

I’m always interested in more efficient methods for extracting this type of information. If you know of other methods I can use then, by all means, let me know.

Don't miss the next post!

Advanced Filtering - Webcast Transcript

Stay with me on this. Alright. First, let's just do some basics. So we're all on the same page, how do you find data in PDQ inventory

© 2021 Corporation


  • PDQ Deploy ®
  • PDQ Inventory ®
  • Enterprise SL
  • Pricing
  • Downloads
  • Licensing
  • Buy