Ron's Sandbox

Processor Type

Friday, 28 March 2008 14:19 by hagermanr

I came across a need to determine what type of OS is installed on a Windows server. The idea being that if it is a 32 bit OS, I'll get a registry key from one location but if it is a 64 bit OS, the key lives in another location.

Using WMI, I simply look up the PROCESSOR_ARCHITECTURE value.

This value is located at \\HKLM\System\CurrentControlSet\Control\Session Manager\Environment.

If you find a need for this, the code is as follows:

sHostName = "host.domain.com"
sArchitecture = ""
const HKEY_LOCAL_MACHINE = &H80000002
sEnvKeyPath = "System\CurrentControlSet\Control\Session Manager\Environment"
sEnvValue = "PROCESSOR_ARCHITECTURE"

on error resume next

Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ sHostName & "\root\default:StdRegProv")

'Read the registry to get the current processor architecture
oRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE, sEnvKeyPath, sEnvValue, sStringValue

if err.number<>0 then
    sArchitecture = "Computer not found"
    err.Clear()
else
    sArchitecture= sStringValue
end if

WScript.Echo sArchitecture

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   VBScript | WMI
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading