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 41 42 43 44 45
| 'Informations sur votre système d'exploitation
Option Explicit
Dim objWMIService,oShell,env,colAdapters,Titre,i,fso,LogFile
Dim colItems,objItem,strComputer,MyInfos,wshnetwork,objAdapter
Titre = "PC Infos"
strComputer = "."
set fso = CreateObject("Scripting.FileSystemObject")
'Nom du fichier qui va stocker le résultat
LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, ".")) & "txt"
if fso.FileExists(LogFile) Then 'Si le fichier LogFile existe
fso.DeleteFile LogFile 'alors on le supprime
end If
set wshnetwork = createobject("wscript.network")
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objItem in colItems
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
MyInfos = "Informations OS " & VbCrLF & VbCrLF & _
"Système d'Exploitation : " & objItem.Caption & VbCrLF & VbCrLF & "Nom de l'ordinateur : " & wshnetwork.computername & VbCrLF & VbCrLF &_
"Adresse MAC : " & objAdapter.MACAddress & VbCrLF & VbCrLF &_
"Adresse IP : " & objAdapter.IPAddress(i)
Next
Next
Call WriteLog(MyInfos,LogFile)
MsgBox MyInfos,64,Titre
oShell.Run LogFile,1,False
'*****************************************************************
'Fonction pour écrire le résultat dans un fichier texte
Sub WriteLog(strText,LogFile)
Dim fs,ts
Const ForAppending = 8
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(LogFile,ForAppending,True)
ts.WriteLine strText
ts.Close
End Sub
'***************************************************************** |
Partager