Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine OS Platform with WMI?

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 thought I had figured it out looking at my Win2k8 system when I found the following:

 Win32_OperatingSystem / OSArchitecture

I was wrong. It doesn't appear that this field exists on Win2k3 systems. Argh!

So, is anyone aware of another field in WMI that "is" the same across server versions? If not, what about a registry key that is the same? I am using a tool that only allows me to configure simple field queries, so I cannot use a complex script to perform.

Any help would be greatly appreciated.

like image 561
user172286 Avatar asked Sep 11 '09 21:09

user172286


People also ask

How do I find the OS of a remote server?

EASIEST METHOD: Click the Windows Start button and type msinfo32 and press Enter. Click View > Remote Computer > Remote Computer on the Network. Type machine name and click OK.

How can I tell what process is using WMI?

1) On your keyboard, press the Windows logo key and X at the same time, then select Event Viewer. 2) Click the View button on top and then Show Analytic and Debug Logs. 3) On the left pane, follow the path: Applications and Service Logs > Microsoft > Windows > WMI Activity > Operational log.

How do I get OS version from WMIC?

You can use wmic os get commands on a Microsoft Windows system to view information related to the operating system via a command-line interface (CLI). E.g., to determine the version of the operating system you can issue the command Windows Management Instrumentation Command-line (WMIC) command wmic os get version .


1 Answers

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 & "}"
like image 182
gudbarnone Avatar answered Oct 28 '22 07:10

gudbarnone