Function getOS() As String
On Error Resume Next
Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Dim objWMIService
Dim colItems, objItem
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objItem In colItems
getOS = "Vous utilisez:" & vbCr & vbCr & _
"Système d'Exploitation: " & objItem.Caption & vbCr & vbCr & _
"Version:" & " " & objItem.version & " " & objItem.CSDVersion & vbCr & _
Application.OperatingSystem
Next objItem
Set objItem = Nothing
End Function
msgbox Application.operatingsystem
Référence du développeur Excel - Application.OperatingSystem
Cette propriété renvoie le nom et le numéro de version du système d'exploitation actif, par exemple:
« Windows (32 bits) 4.00 » ou « Macintosh 7.00 ». Type de données String en lecture seule.
Your Windows is detected as 64bit (x64).
--------------------------------//--------------------------------
Name: Windows 7 Home Premium
Version: 6.1.7601
Service Pack: Service Pack 1
Type: Multiprocessor Free
Install. Date: vendredi 16 septembre 2011
Processor: Your CPU supports 64bit (x64) operating systems.
--------------------------------//--------------------------------
64bit Checker, v1.1
Sub a()
MsgBox Environ(14) ' test OK XP PRO + Excel 2003 : renvoie : OS=Windows XP
MsgBox Environ(19) ' dommage ! (XP Home SP3 + Excel 2000): renvoie OS=Windows_NT
End Sub
Sub Dans_Les_Environs_OUESTLOS()
Dim i
For i = 1 To 35
Debug.Print i & Space(10) & Environ(i)
Next i
End Sub
Option Explicit
Sub Dans_Les_Environs_OUESTLOS()
Dim i
For i = 1 To 35
'Debug.Print i & Space(10) & Environ(i)
Cells(i, 1) = Environ(i)
Next i
End Sub
15 OS=Windows_NT
Cordialement1 ALLUSERSPROFILE
2 APPDATA
3 asl.log
4 CLASSPATH
5 CommonProgramFiles
6 COMPUTERNAME
7 ComSpec
8 FP_NO_HOST_CHECK
9 HOMEDRIVE
10 HOMEPATH
11 LOCALAPPDATA
12 LOGONSERVER
13 NUMBER_OF_PROCESSORS
14 OnlineServices
15 OS
16 Path
17 PATHEXT
18 PCBRAND
19 PLATFORM
20 PROCESSOR_ARCHITECTURE
21 PROCESSOR_IDENTIFIER
22 PROCESSOR_LEVEL
23 PROCESSOR_REVISION
24 ProgramData
25 ProgramFiles
26 PSModulePath
27 PUBLIC
28 QTJAVA
29 RoxioCentral
30 SESSIONNAME
31 SystemDrive
32 SystemRoot
33 TEMP
34 TMP
35 USERDOMAIN
Sub Test4VistaSeven()
Dim Obj, oStr
Set Obj = GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_OperatingSystem")
Set oStr = Obj.ItemIndex(0)
MsgBox oStr.Description
End Sub
... Etant actuellement sous XP, quelqu'un sous Vista ou Seven peut-il tester le code ci-dessous, svp...