Kkweit Posted March 30, 2010 Posted March 30, 2010 Hi everybody, No need to tell that i'm a newbie with AutoIt. I couldn't find a solution to my problem sorry if somebody already answered something like this but idon't think so. Context: The following script is working (i got error message but it's working) $yyyymd = @MDAY & "/" & @MON & "/" & @YEAR $ping = Ping("192.168.80.1", 1200) $ping2 = Ping("www.google.fr", 1200) $File = "C:\Program Files\TeamViewer\Version4\TeamViewer.exe" MsgBox(64,"Resultat du test permettant d'etablir un diagnostic de votre machine", _ "Date : " & $yyyymd & @CRLF & _ "Adresse IP de la machine : " & @IPAddress1 & @CRLF & _ "Adresse IP de la passerelle : " & GetLanGW() & @CRLF & _ "Adresse IP du serveur DNS : " & GetLanDNS() & @CRLF & _ "Resultat du ping de la passerelle (si different de 0 = OK) : " & $ping & " ms" & @CRLF & _ "Resultat du ping de google.fr (si different de 0 = OK) : " & $ping2 & " ms" & @CRLF & _ "Cliquez sur Ok pour valider ce rapport et lancer l'outil de prise en main a distance" & @CRLF) $csn = Run("C:\Program Files\TeamViewer\Version4\TeamViewer.exe") ShellExecute ($csn) $url = "http://support.netoptima.fr/" ShellExecute ($url) Func GetLanGW() Local $colItems = "" Local $strComputer = "localhost" Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DefaultIPGateway(0)) > 3) Then If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) EndIf Next Else Return @IPAddress1 ; if you dont have Gateway EndIf EndFunc ;==>GetLanGW Func GetLanDNS() Local $colItems = "" Local $strComputer = "localhost" Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DNSServerSearchOrder(0)) > 3) Then If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) EndIf Next Else Return @IPAddress1 ; if you dont have DNS EndIf EndFunc ;==>GetLanDNS Here is my problem I would like to extract the informations from my script and send them by email here is the second (no need to say that it doesn't works) $s_SmtpServer = "mail.netoptima.fr" ; to be completed $s_FromName = "Kapi l'international" ; to be completed $s_FromAddress = "Kapi-linternational@intechinfo.fr" ; to be completed $s_ToAddress = "a-k_93@hotmail.fr"; yours Dim $t_Body[1] $t_Body[0] = "'Resultat du test permettant d'etablir un diagnostic de votre machine:', & @CRLF & _ 'Date : ' & $yyyymd & @CRLF & _ 'Adresse IP de la machine : ' & @IPAddress1 & @CRLF & _ 'Adresse IP de la passerelle : ' & GetLanGW() & @CRLF & _ 'Adresse IP du serveur DNS : ' & GetLanDNS() & @CRLF & _ 'Resultat du ping de la passerelle (si different de 0 = OK) : ' & $ping & ' ms' & @CRLF & _ 'Cliquez sur Ok pour valider ce rapport et ouvrir une fenetre vers l outil de prise en main' & @CRLF" $s_Subject = "Presentation du nouveau directeur de l'ecole" if _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $t_Body) Then msgbox(0,"OK","no error") Else msgbox(0,"error",@ERROR) EndIf Is there anybody who can help me ?
jchd Posted March 30, 2010 Posted March 30, 2010 (edited) Bienvenue sur le forum,Can you please use AutoIt tags to bracket code next time, else it becomes more difficult to read and eats up real estate uselessly. Use the small AutoIt square icon under the bold button and click Add, then paste your code [Аutoit]there[/Аutoit]. Don't copy-paste my example, it's magically made to fail!Don't forget that the search feature is there to help you, just like the help file.Also posting code and saying "it doesn't work" puts the burden of trying to figure what error _you_ get when _you_ run the code to potential helpers, certainly not the best way to incitate others to give you a hand. Understand that it's much harder than if you post code and error message or expose what you regard as unexpected behavior.Lastly you really should insert error checking code in your programs. What's the purpose of taking pain to carefully report errors in UDF functions if you don't even bother to check for in your application?I'm not being rude, just trying to explain why your question is akward as written. http://www.beiww.com/doc/oss/smart-questions.htmlEdit: the chinese version of url is , well, chinese! Here's the good one. Edited March 30, 2010 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Kkweit Posted March 30, 2010 Author Posted March 30, 2010 Ok. Next time i will do it right. I just got my problem solved by myself so the point of this topic is useless. Just in case here is my script. (It sends some computer information's by email) $s_SmtpServer = "mail.netoptima.fr" ; to be completed $s_FromName = "Kapi l'international" ; to be completed $s_FromAddress = "Kapi-linternational@intechinfo.fr" ; to be completed $s_ToAddress = "a-k_93@hotmail.fr"; yours $yyyymd = @MDAY & "/" & @MON & "/" & @YEAR $ip = @IPAddress1 $ping = Ping("192.168.80.1", 1200) $ping2 = Ping("www.google.fr", 1200) Dim $t_Body[6] $t_Body[0] = "Date : " & $yyyymd & @CRLF $t_Body[1] = "Adresse IP de la machine : " & @IPAddress1 & @CRLF $t_Body[2] = "Adresse IP de la passerelle : " & GetLanGW() & @CRLF $t_Body[3] = "Adresse IP du serveur DNS : " & GetLanDNS() & @CRLF $t_Body[4] = "Resultat du ping de la passerelle (si different de 0 = OK) : " & $ping & " ms" & @CRLF $t_Body[5] = "Resultat du ping de googgle.fr (si different de 0 = OK) : " & $ping2 & " ms" & @CRLF ;'Cliquez sur Ok pour valider ce rapport et ouvrir une fenetre vers l outil de prise en main' & @CRLF" $s_Subject = "Resultat du test permettant d'etablir un diagnostic de votre machine:" if _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $t_Body) Then msgbox(0,"OK","no error") Else msgbox(0,"error",@ERROR) EndIf Func GetLanGW() Local $colItems = "" Local $strComputer = "localhost" Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DefaultIPGateway(0)) > 3) Then If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0) EndIf Next Else Return @IPAddress1 ; if you dont have Gateway EndIf EndFunc ;==>GetLanGW Func GetLanDNS() Local $colItems = "" Local $strComputer = "localhost" Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DNSServerSearchOrder(0)) > 3) Then If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0) EndIf Next Else Return @IPAddress1 ; if you dont have DNS EndIf EndFunc ;==>GetLanDNS
jchd Posted March 30, 2010 Posted March 30, 2010 Glad to see you got it fixed. Btw you used the quote button, not the AutoIt button but you'll get it next for sure. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
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