Le script que j'ai réussi à créer avec l'utilisation de plusieurs exemples du forum:
► Afficher le texteMon Code
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
; utilisation de compuinfo.au3,para et de l'aide du forum autoitscript.com et .fr
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $VOL, $SERIAL, $TOTAL, $FREE_C, $FREE_D, $FREE_E
Local $Input_Computer_cm, $Input_ComputerName, $Input_CurrentUserName, $Input_OperatingSystem, $Input_imp, $imp, $var, $mem, $Input_mem
Local $Input_ServicePack, $Input_VolumeLabel, $Input_SerialNumber
Local $Input_TotalSpace, $Input_FreeSpace, $Input_IpAddress, $Input_StartupDirectory
Local $Input_WindowsDirectory, $Input_SystemFolderDirectory, $Input_DesktopDirectory
Local $Input_MyDocumentsDirectory, $Input_ProgramFilesDirectory, $Input_StartMenuDirectory
Local $Input_TemporaryFileDirectory, $Input_DesktopWidth, $Input_DesktopHeight
Local $Input_Date,$logiciels, $Input_Time, $msg, $cm, $processeur,$Input_Processeur,$Input_mac,$NbrNet,$mac
Local $result,$Software,$app,$Napp,$logi,$Input_logi,$text,$file
If Not(IsDeclared("$cI_CompName")) Then
Global $cI_CompName = @ComputerName
EndIf
Global Const $cI_VersionInfo = "00.03.08"
Global Const $cI_aName = 0, _
$cI_aDesc = 4
Global $wbemFlagReturnImmediately = 0x10, _ ;DO NOT CHANGE
$wbemFlagForwardOnly = 0x20 ;DO NOT CHANGE
Global $ERR_NO_INFO = "Array contains no information", _
$ERR_NOT_OBJ = "$colItems isnt an object"
; liste des logiciels à vérifier; chacun doit être séparé par des , et l'ensemble par des "
$logiciels="microsoft office,firefox,scan"
$VOL = DriveGetLabel("C:\")
$SERIAL = DriveGetSerial("C:\")
$TOTAL = DriveSpaceTotal("C:\")/1024
$FREE_C = DriveSpaceFree("C:\")/1024
$FREE_D = DriveSpaceFree("D:\")/1024
$FREE_E = DriveSpaceFree("E:\")/1024
;test pour les modèles d'imprimantes
For $i= 1 to 20
$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers", $i)
If @error <> 0 then ExitLoop
$imp=$var &" , "&$imp
Next
$mem = MemGetStats()
$mem = $mem[1]/1000
;logiciels installés
_Version($Software)
If @error Then
$error = @error
$extended = @extended
Switch $extended
Case 1
_ErrorMsg("Array contains no data.")
EndSwitch
EndIf
$app = StringSplit($logiciels, ",")
For $i = 1 To $Software[0][0] Step 1
For $Napp=1 To $app[0]
If @error <> 0 Then ExitLoop
$result=StringInStr($Software[$i][0],$app[$Napp])
If $result=0 then ContinueLoop
$logi=$Software[$i][0]&$Software[$i][1]&", "&$logi
Next
Next
;adresse mac
Dim $NetworkCards
_ComputerGetNetworkCards($NetworkCards)
If @error Then
$error = @error
$extended = @extended
Switch $extended
Case 1
_ErrorMsg($ERR_NO_INFO)
Case 2
_ErrorMsg($ERR_NOT_OBJ)
EndSwitch
EndIf
For $i = 1 To $NetworkCards[0][0] Step 1
$NbrNet=StringInStr($NetworkCards[$i][0],"100")
if $NbrNet=0 then ContinueLoop
if $nbrNet=0 Then ContinueLoop
$mac=$NetworkCards[$i][1]
;MsgBox(0, "Test _ComputerGetNetworkCards", "Name: " & $NetworkCards[$i][0] & @CRLF & _
; "MAC Address: " & $NetworkCards[$i][1] &"adresse IP" & $NetworkCards[$i][2]&@CRLF)
Next
;carte mère
call ("cm")
$cm=cm()
Dim $Processors
_ComputerGetProcessors($Processors)
If @error Then
$error = @error
$extended = @extended
Switch $extended
Case 1
_ErrorMsg($ERR_NO_INFO)
Case 2
_ErrorMsg($ERR_NOT_OBJ)
EndSwitch
EndIf
For $i = 1 To $Processors[0][0] Step 1
$processeur=$Processors[$i][0]&", "& $Processors[$i][1] &"Mhz, " & $Processors[$i][2]
Next
if $cmdline[0]=0 then $text=0
$file = FileOpen("c:\windows\temp\"&@ComputerName&".txt", 2)
; vérifie si le fichier est ouvert en écriture
If $file = -1 Then
MsgBox(0, "Erreur", "impossible d'ouvrir le fichier"&@ComputerName&".txt"&"en écriture.")
Exit
EndIf
FileWrite($file, @ComputerName&"; "&@MDAY & "/" & @MON & "/" & @YEAR&"; " &@UserName&"; Fabricant, modèle de carte mère "&$cm&"; "&$processeur&"; Mémoire :"&$mem&"; "&@OSServicePack&"; "&@IPAddress1&";Adresse Mac: "&$mac&"; Espace disponible C: "&$FREE_C&"; Imprimante: "&$imp&"; Version des Logiciels: "&$logi&@CRLF&@CRLF)
FileClose($file)
if $Cmdline[0]=0 Then
GUICreate("Information PC - Para, compuinfo.au3 et modifié par Jérôme", 469, 639, (@DesktopWidth - 469) / 2, (@DesktopHeight - 639) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUICtrlCreateLabel("Nom du PC", 10, 10, 150, 20)
GUICtrlCreateLabel("Fabricant, modèle de carte mère", 10, 40, 160, 20)
GUICtrlCreateLabel("Processeur", 10, 70, 160, 20)
GUICtrlCreateLabel("Utilisateur Courant", 10, 100, 150, 20)
GUICtrlCreateLabel("Service Pack", 10, 130, 150, 20)
GUICtrlCreateLabel("C: Volume Label", 10, 160, 150, 20)
GUICtrlCreateLabel("C: Numéro de série", 10, 190, 150, 20)
GUICtrlCreateLabel("C: Espace Total", 10, 220, 150, 20)
GUICtrlCreateLabel("C: Espace Disponible en Go", 10,250, 150, 20)
GUICtrlCreateLabel("D: Espace Disponible en Go", 10,280, 150, 20)
GUICtrlCreateLabel("E: Espace Disponible en Go", 10,310, 150, 20)
GUICtrlCreateLabel("Adresse Ip", 10, 340, 150, 20)
GUICtrlCreateLabel("Adresse Mac", 10, 370, 150, 20)
GUICtrlCreateLabel("Dossier Mes Documents", 10, 400, 150, 20)
GUICtrlCreateLabel("Dossier Temporaire V utilisateur", 10, 430, 150, 20)
GUICtrlCreateLabel("Résolution", 10, 460, 150, 20)
GUICtrlCreateLabel("Date et Heure ", 10, 490, 150, 20)
GUICtrlCreateLabel("Imprimante ", 10, 520, 150, 20)
GUICtrlCreateLabel("Mémoire en Mo ", 10, 550, 150, 20)
GUICtrlCreateLabel("Version des logiciels ", 10, 580, 150, 20)
$Input_Computer_cm= GUICtrlCreateInput("" & @ComputerName, 180, 10, 280, 20)
$Input_ComputerName = GUICtrlCreateInput("" & $cm, 180, 40, 280, 20)
$Input_Processeur= GUICtrlCreateInput("" & $processeur, 180, 70, 280, 20)
$Input_CurrentUserName = GUICtrlCreateInput("" & @UserName, 180, 100, 280, 20)
$Input_ServicePack = GUICtrlCreateInput("" & @OSServicePack, 180, 130, 280, 20)
$Input_VolumeLabel = GUICtrlCreateInput("" & $VOL, 180, 160, 280, 20)
$Input_SerialNumber = GUICtrlCreateInput("" & $SERIAL, 180, 190, 280, 20)
$Input_TotalSpace = GUICtrlCreateInput("" & $TOTAL, 180, 220, 280, 20)
$Input_FreeSpace = GUICtrlCreateInput("" & $FREE_C, 180, 250, 280, 20)
$Input_FreeSpace = GUICtrlCreateInput("" & $FREE_D, 180, 280, 280, 20)
$Input_FreeSpace = GUICtrlCreateInput("" & $FREE_E, 180, 310, 280, 20)
$Input_IpAddress = GUICtrlCreateInput("" & @IPAddress1, 180, 340, 280, 20)
$Input_Mac = GUICtrlCreateInput("" & $mac, 180, 370, 280, 20)
$Input_MyDocumentsDirectory = GUICtrlCreateInput("" & @MyDocumentsDir, 180, 400, 280, 20)
$Input_TemporaryFileDirectory = GUICtrlCreateInput("" & @TempDir, 180, 430, 280, 20)
$Input_DesktopWidth = GUICtrlCreateInput("" & @DesktopWidth &"*"&@DesktopHeight, 180, 460, 280, 20)
$Input_Date = GUICtrlCreateInput(" " &@MDAY & "/" &@MON & "/"&@YEAR, 180, 490, 280, 20)
$Input_imp = GUICtrlCreateInput(" "& $imp, 180, 520, 280, 20)
$Input_mem = GUICtrlCreateInput(" "& $mem, 180, 550, 280, 20)
$Input_logi= GUICtrlCreateInput(" "& $logi, 180, 580, 280, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;
EndSelect
WEnd
Exit
Else
EndIf
EndFunc ;==>_Main
Exit
;recupère le modèle de la carte mère
Func Cm()
Local $WMI, $objs, $sAns
$WMI = ObjGet("WinMgmts:")
$objs = $WMI.InstancesOf("Win32_BaseBoard")
For $obj In $objs
$sAns = $sAns & $obj.Manufacturer & "," & $obj.Product
Next
Return $sAns
EndFunc
;permet de rechercher les programmes en recherchant dans le registre
Func _Version(ByRef $aSoftwareInfo)
Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Local $i = 1
Dim $aSoftwareInfo[1][4]
Local $AppKey
While 1
$AppKey = RegEnumKey($UnInstKey, $i)
If @error <> 0 Then ExitLoop
ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][2]
$aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
$aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
$i += 1
WEnd
$aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
If $aSoftwareInfo[0][0] < 1 Then
SetError(1, 1, 0)
EndIf
EndFunc
;permet de récuperer le nom et la fréquence du processeur
Func _ComputerGetProcessors(ByRef $aProcessorInfo)
Local $colItems, $objWMIService, $objItem
Dim $aProcessorInfo[1][42], $i = 1
$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
ReDim $aProcessorInfo[UBound($aProcessorInfo) + 1][4]
$aProcessorInfo[$i][0] = StringStripWS($objItem.Name, 1)
$aProcessorInfo[$i][1] = $objItem.MaxClockSpeed
$aProcessorInfo[$i][2] = $objItem.Status
$i += 1
Next
$aProcessorInfo[0][0] = UBound($aProcessorInfo) - 1
If $aProcessorInfo[0][0] < 1 Then
SetError(1, 1, 0)
EndIf
Else
SetError(1, 2, 0)
EndIf
EndFunc ;_ComputerGetProcessors
Func _ComputerGetNetworkCards(ByRef $aNetworkInfo)
Local $colItems, $objWMIService, $objItem
Dim $aNetworkInfo[1][34], $i = 1
$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
ReDim $aNetworkInfo[UBound($aNetworkInfo) + 1][3]
$aNetworkInfo[$i][0] = $objItem.Name
$aNetworkInfo[$i][1] = $objItem.MACAddress
$aNetworkInfo[$i][2] = $objItem.NetworkAddresses
$i += 1
Next
$aNetworkInfo[0][0] = UBound($aNetworkInfo) - 1
If $aNetworkInfo[0][0] < 1 Then
SetError(1, 1, 0)
EndIf
Else
SetError(1, 2, 0)
EndIf
EndFunc ;_ComputerGetNetworkCards
Func __StringToDate($dtmDate)
Return (StringMid($dtmDate, 5, 2) & "/" & _
StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
& " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc ;__StringToDate Function created by SvenP Modified by JSThePatriot
*Créer des onglets afin de mieux organiser les valeurs: Par exemple un onglet pour la partie logiciel et un autre pour le matériel
*Je voudrai aussi changer la couleur du fond des GUICtrlCreateInput lorsque la valeur retourné est incorrecte.
Pouvez vous me donner des pistes pour faire cela.
Merci