VBA Function - Return Windows Version Details (1 Viewer)

Status
Not open for further replies.

Rx_

Nothing In Moderation
Local time
Today, 00:45
Joined
Oct 22, 2009
Messages
2,803
Code:
Public Function winVer()
On Error Resume Next
  Dim strMessage As String
  
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" _
      & strComputer & "\root\cimv2")
  Set colOperatingSystems = objWMIService.ExecQuery _
      ("Select * from Win32_OperatingSystem")
  For Each objOperatingSystem In colOperatingSystems
      strMessage = objOperatingSystem.Caption & _
      "  " & objOperatingSystem.Version
  Next
  
  Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" _
      & strComputer & "\root\cimv2")
  Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", , 48)
  For Each objItem In colItems
  strMessage = strMessage & "  " & objItem.AddressWidth & "  Bit"
  Next
  
  MsgBox strMessage
  End Function
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:45
Joined
May 7, 2009
Messages
19,169
that is very good. i also have one, much faster.
Code:
Public Sub subWindowsVer()
Dim objShell, strRegisteredUser, strProduct, Proc
Set objShell = CreateObject("wscript.shell")
strRegisteredUser = objShell.RegRead("HKLM\Software\Microsoft\" & _
"Windows NT\CurrentVersion\RegisteredOwner")
strProduct = objShell.RegRead("HKLM\Software\Microsoft\Windows NT\" & _
"CurrentVersion\ProductName")
Proc = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
MsgBox strRegisteredUser & " is running " & strProduct & IIf(Proc = "x86", " 32", " 64") & " bit"
'Debug.Print strRegisteredUser & " is running " & strProduct & IIf(Proc = "x86", " 32", " 64") & " bit OS"
End Sub
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom