1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| MsgBox FindOSType("."),64,"Système d'exploitation"
Function FindOSType(strComputer)
'Defining Variables
Dim objWMI, objItem, colItems
Dim OSVersion, OSName, ProductType
'Get the WMI object and query results
Set objWMI = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)
'Get the OS version number (first two) and OS product type (server or desktop)
For Each objItem in colItems
OSVersion = Left(objItem.Version,3)
ProductType = objItem.ProductType
Next
'Time to convert numbers into names
Select Case OSVersion
Case "6.1"
OSName = "Windows 7"
Case "6.0"
OSName = "Windows Vista"
Case "5.2"
OSName = "Windows 2003"
Case "5.1"
OSName = "Windows XP"
Case "5.0"
OSName = "Windows 2000"
Case "4.0"
OSName = "Windows NT 4.0"
Case Else
OSName = "Windows 9x"
End Select
'Return the OS name
FindOSType = OSName
'Clear the memory
Set colItems = Nothing
Set objWMI = Nothing
End Function |
Partager