Jac Posted November 13, 2007 Posted November 13, 2007 Hi guys i have this script $colSettings = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystemProduct") For $objComputerSystemProduct In $colSettings $Serial_Number = $objComputerSystemProduct.IdentifyingNumber $Modele = $objComputerSystemProduct.Vendor & " " & $objComputerSystemProduct.Version & " " & $objComputerSystemProduct.Name Next IniWrite($NOM_PC,"Système","Numéro De Série",$Serial_Number) IniWrite($NOM_PC,"Système","Modèle",$Modele & @CRLF) On one pc i get this error Error: Variable must be of type "Object" I join a screenshot Thanks to help me
Klaatu Posted November 13, 2007 Posted November 13, 2007 Hi guys i have this script $colSettings = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystemProduct")Looks like you're missing something at the start of your script:$strComputer = "localhost" $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $wmiLocator.ConnectServer($strComputer, "root\cimv2", "user", "password") Maybe something like that? The way you have it now $objWMIService is not an object when the script first starts; you have to assign an object to it before using it as an object. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
olivertwistcoder Posted March 21, 2008 Posted March 21, 2008 i've tried to realize something like you want. See it : expandcollapse popup#Include <date.au3> #include <file.au3> #Include <GUIconstants.au3> $share = IniRead("cfgconst.ini", "Partage", "key", "NotFound") $letter = IniRead("cfgconst.ini", "Lettre", "key", "NotFound") $user = IniRead("cfgconst.ini", "User", "key", "NotFound") $nb = IniRead("cfgconst.ini", "NbServeurs", "key", "NotFound") $replog = IniRead("cfgconst.ini", "Replogs", "key", "NotFound") If FileExists("cryptage.ini") Then $PASSKEY = "PASSWORD" $M_PASSWORD =IniRead("cryptage.ini","program","password","") $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD)) Else $PASSKEY = "PASSWORD" $PASSWORD=InputBox("Prompt","Tapez le mot de passe à sauvegarder : ","","*") $TEMP = Str2Hex(Crypt($PASSKEY,$PASSWORD)) IniWrite("cryptage.ini","program","password",$TEMP) $PASSWORD=InputBox("Prompt","Tapez le mot de passe pour vérification avec la version enregistrée : ","","*") $M_PASSWORD =IniRead("cryptage.ini","program","password","") $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD)) If $M_PASSWORD == $PASSWORD Then MsgBox(0,'Ok', "Les mots de passe correspondent.") Else MsgBox(16,'Houlala !!!', "Les mots de passe correspondent pas !!!") FileDelete("cryptage.ini") Exit EndIf EndIf Func Crypt($PASS, $STRG) $A = 1 $N_STRG = "" For $I = 1 To StringLen($STRG) $B = Asc(StringMid($PASS, $A, 1)) $A = $A + 1 If $A > StringLen($PASS) Then $A = 1 $N_STRG = $N_STRG & Chr(BitXOR(Asc(StringMid($STRG, $I, 1)),$B)) Next Return $N_STRG EndFunc Func Str2Hex($STRG) $H = "" For $I = 1 To StringLen($STRG) $H = $H & String(Hex(Asc(StringMid($STRG, $I, 1)),2)) Next Return $H EndFunc Func Hex2Str($H) $STRG = "" For $I = 1 To StringLen($H) Step 2 $STRG = $STRG & Chr(Dec(StringMid($H, $I, 2))) Next Return $STRG EndFunc $serv = IniRead("serverslist.ini", "Serveur1", "key", "NotFound") $repserv = StringReplace($serv, "\", "") $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = $repserv $Output = "" $Output = $Output & "Ordinateur : " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $wmiLocator.ConnectServer($strComputer, "root\cimv2", $user, $M_PASSWORD) $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $LastBootUp = WMIDateStringToDate($objItem.LastBootUpTime) $LocalDateTime = WMIDateStringToDate($objItem.LocalDateTime) $Output = $Output & "En années : " & _DateDiff("Y", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En mois : " & _DateDiff("M", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En semaines : " & _DateDiff("W", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En jours : " & _DateDiff("D", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En heures : " & _DateDiff("h", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En Minutes : " & _DateDiff("n", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "En Secondes : " & _DateDiff("s", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "Dernier Reboot : " & $LastBootUp & @CRLF $Output = $Output & "Heure locale machine : " & $LocalDateTime & @CRLF If MsgBox(1, "WMI Output", $Output) = 2 Then ExitLoop $Output = "" Next Else MsgBox(0, "WMI Output", "Pas d'objets WMI trouvés pour cette classe : " & "Win32_OperatingSystem") EndIf Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 1, 4) & "/" & StringMid($dtmDate, 5, 2) & "/" & StringMid($dtmDate, 7, 2) & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2)) EndFunc ;==>WMIDateStringToDate So you need 2 ini files : cfgconst.ini [Partage] Key=c$ [Lettre] Key=X: [User] Key=administrateur [NbServeurs] Key=8 [Replogs] Key=admintoolslogs and the second will be created when launch the au3 : cryptage.ini, to encrypt your admin pwd. And at this time, i'm working on a multiple connection to several servers to get their own launch time. Help you ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now