Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB
Expertise: Intermediate
Nov 11, 2003

Get Windows Name Using WMI

Here's an easy way to get OS information using the Windows Management Instrument (WMI):

Private Sub getWindowsInfo()
  On Error Resume Next

  Dim strComputername As String
  Dim objWMIService   As Object
  Dim objQrySetting   As Object
  Dim objOS           As Object

  strComputername = "." ' Local computer
  Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputername
& "\root\cimv2")
  Set objQrySetting = objWMIService.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
  For Each objOS In objQrySetting
      MsgBox "OS Name: " & objOS.Name & vbCrLf & _
            "Version: " & objOS.Version & vbCrLf & _
            "Service Pack: " & objOS.ServicePackMajorVersion & "." &
objOS.ServicePackMinorVersion & vbCrLf & _
            "OS Manufacturer: " & objOS.Manufacturer & vbCrLf & _
            "Windows Directory: " & objOS.WindowsDirectory & vbCrLf & _
            "Locale: " & objOS.Locale
  Next
  ' Tidy up
  Set objWMIService = Nothing
  Set objQrySetting = Nothing
  Set objOS = Nothing

End Sub
Leng Dieb
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap