Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

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
  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
  ' 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.



Thanks for your registration, follow us on our social networks to keep up-to-date