Fonction pour détecter si l’on se trouve sur un ordinateur fixe ou un ordinateur portable. Permet d’installation les applications nomades sur les portables.
Voici une petite fonction VBS qui détecte un ordinateur portable sur les composants suivants :
- Carte PCMCIA
- Batterie
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 |
' Exemple d'utilisation If CheckTypePC <> "Desktop" Then 'Ordinateur Portable Else 'Ordinateur Fixe End If Function CheckTypePC () On Error Resume Next Dim objWMIService,colItems,objItem Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select DeviceID from Win32_PCMCIAController",,48) For Each objItem in colItems If Not (objItem.DeviceID = "") Then CheckTypePC = "Notebook" Exit For End If Next Set colItems = objWMIService.ExecQuery("Select DeviceID from Win32_PortableBattery",,48) For Each objItem in colItems If Not (objItem.DeviceID = "") Then CheckTypePC = "Notebook" Exit For End If Next Set colItems = objWMIService.ExecQuery("Select DeviceID from Win32_Battery",,48) For Each objItem in colItems If Not (objItem.DeviceID = "") Then CheckTypePC = "Notebook" Exit For End If Next If CheckTypePC = "" Then CheckTypePC = "Desktop" Set objWMIService = Nothing End Function |
Cet article n'a pas été revu depuis la publication.
Cet article a été créé par david le 26 décembre 2016.
Laisser un commentaire