13lack13lade Posted October 30, 2013 Share Posted October 30, 2013 (edited) hey guys, using standard CDO sending script, set it up to task scheduler, worked absolutely fine... (it runs at midnight) and last night my phone starts going mental constantly receiving emails.. There is no looping in the script or anything like that what so ever.. i come in this morning the script has over 100 copies open, after testing the script will open a copy of the script. WTF?!?!?! expandcollapse popup#include <Date.au3> #Include<file.au3> #include<ie.au3> ;date function & variable Func _Convert($date) Return StringRegExpReplace($date, '\d\d(\d\d)/(\d\d)/(\d\d)', '$3$2$1') EndFunc $today = _NowCalcDate() $yesterday = _DateAdd('d', -1, $today) ;open program & login Run("C:\Program Files (x86)\program.exe") - Sleep(4000) Send("{ENTER}") Sleep(2000) Send("dataload") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("****") Sleep(1000) Send("{ENTER}") Sleep(1000) ;reporting Send("ras") Sleep(700) Send("{ENTER}") Sleep(700) Send("removed") ;report name Sleep(700) Send("{ENTER}") sleep (700) Send("*") ;parameter one sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter two sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter three sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter four sleep(500) send("{ENTER}") sleep(500) Send("H") ;parameter five sleep(500) send("{ENTER}") sleep(500) Send("dxb") ;parameter six sleep(500) send("{ENTER}") sleep(500) Send("ara") ;parameter seven sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter eight sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter nine sleep(500) send("{ENTER}") sleep(500) Send(_convert($yesterday)) ;parameter ten ' yesterdays date sleep(500) send("{ENTER}") sleep(500) Send(_convert($today)) ;parameter 11 ' todays sleep(500) send("{ENTER}") sleep(500) Send(_convert($today)) ;parameter 12 ' todays sleep(500) send("{ENTER}") sleep(500) Send("311014") ;parameter 13 ' end of october 2014 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 14 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 15 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 16 sleep(500) send("{ENTER}") Sleep (500) send("F") ;output to file sleep (500) send("{ENTER}") sleep (500) send("removed") ; save as report name sleep (500) send("{ENTER}") sleep (500) send("y") ;overwrite file sleep (500) send("{ENTER}") sleep (500) send("{ENTER}") sleep (500) send("{ENTER}") sleep (500) ;exit calypso; Send("X") sleep(500) Send("{ENTER}") Send("X") sleep(500) Send("{ENTER}") Send("X") sleep(500) Send("{ENTER}") sleep(500) winclose("Program Host") sleep(600000) ; EMAIL Global $smtpserver = "removed" Global $fromname = "removed" Global $fromaddress = "removed" Global $toaddress = "removed" Global $subject = "" Global $body = "removed" Global $attachfiles = "removed" Global $ccaddress = "" Global $bccaddress = "" Global $importance = "Normal" Global $username = "" Global $password = "" Global $ipport = 25 Global $ssl = 0 Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc EDIT* Figured out the problem, i created the script on my win7 comp and using on xp thus programfiles is not C:Program Files (x86) but is actually C:Program Files Can anyone explain to me why it would open a copy of itself when it couldn't find the run file path? Edited October 30, 2013 by 13lack13lade Link to comment Share on other sites More sharing options...
BrewManNH Posted October 30, 2013 Share Posted October 30, 2013 Show the script, show how you set up the task schedule, then you will get an answer. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted October 30, 2013 Developers Share Posted October 30, 2013 What is the name of your compiled script and the name of the real program you are running in the script? In other words: Could it be constantly shelling itself? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
13lack13lade Posted October 30, 2013 Author Share Posted October 30, 2013 (edited) name of script - AAScript.exe program - Netterm.exe Ive found that for whatever reason the issue can be recreated and solved because the run filepath: Run("C:Program Files (x86)InterSoft International, IncNetTermnetterm.exe") is the filepath for my win7 pc however windows XP the correct line should be: Run("C:Program FilesInterSoft International, IncNetTermnetterm.exe") When i run the win7 filepath on my xp it just starts opening the script over and over and over - i know(now) its the incorrect filepath but im just trying to understand why the script would re-open its self at all. My thinking is that shouldnt it have failed to open the program, send the keystrokes to the empty screen, then run the CDO once..? Task Scheduler set to daily(weekdays), 12:01am, run once. :/ Exact script minus email information: expandcollapse popup#include <Date.au3> #Include<file.au3> #include<ie.au3> ;date function & variable Func _Convert($date) Return StringRegExpReplace($date, '\d\d(\d\d)/(\d\d)/(\d\d)', '$3$2$1') EndFunc $today = _NowCalcDate() $yesterday = _DateAdd('d', -1, $today) ;open calypso & login Run("C:\Program Files\InterSoft International, Inc\NetTerm\netterm.exe") Sleep(4000) Send("{ENTER}") Sleep(2000) Send("dataload") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("Load") Sleep(1000) Send("{ENTER}") Sleep(1000) ;reporting Send("ras") Sleep(700) Send("{ENTER}") Sleep(700) Send("k_arabian") ;report name Sleep(700) Send("{ENTER}") sleep (700) Send("*") ;parameter one sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter two sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter three sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter four sleep(500) send("{ENTER}") sleep(500) Send("H") ;parameter five sleep(500) send("{ENTER}") sleep(500) Send("dxb") ;parameter six sleep(500) send("{ENTER}") sleep(500) Send("ara") ;parameter seven sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter eight sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter nine sleep(500) send("{ENTER}") sleep(500) Send(_convert($yesterday)) ;parameter ten ' yesterdays date sleep(500) send("{ENTER}") sleep(500) Send(_convert($today)) ;parameter 11 ' todays sleep(500) send("{ENTER}") sleep(500) Send(_convert($today)) ;parameter 12 ' todays sleep(500) send("{ENTER}") sleep(500) Send("311014") ;parameter 13 ' end of october 2014 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 14 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 15 sleep(500) send("{ENTER}") sleep(500) Send("*") ;parameter 16 sleep(500) send("{ENTER}") Sleep (500) send("F") ;output to file sleep (500) send("{ENTER}") sleep (500) send("arabian_adventures.xls") ; save as report name sleep (500) send("{ENTER}") sleep (500) send("y") ;overwrite file sleep (500) send("{ENTER}") sleep (500) send("{ENTER}") sleep (500) send("{ENTER}") sleep (500) ;exit calypso; Send("X") sleep(500) Send("{ENTER}") Send("X") sleep(500) Send("{ENTER}") Send("X") sleep(500) Send("{ENTER}") sleep(500) winclose("Calypso Host") sleep(600000) ; EMAIL Global $smtpserver = "" Global $fromname = "" Global $fromaddress = "" Global $toaddress = "" Global $subject = "" Global $body = "" Global $attachfiles = "" Global $ccaddress = "" Global $bccaddress = "" Global $importance = "Normal" Global $username = "" Global $password = "" Global $ipport = 25 Global $ssl = 0 Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom Exit ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc Edited October 30, 2013 by 13lack13lade Link to comment Share on other sites More sharing options...
AdamUL Posted October 31, 2013 Share Posted October 31, 2013 (edited) Instead of using a hard coded path for the executable, use the @ProgramFilesDir macro. Try this.Run(@ProgramFilesDir & "\InterSoft International, Inc\NetTerm\netterm.exe")This will work on both systems, as long as the script is compiled as 32-bit. Adam Edited October 31, 2013 by AdamUL Link to comment Share on other sites More sharing options...
13lack13lade Posted November 5, 2013 Author Share Posted November 5, 2013 Thanks for the tip Adam! any explanation as to why it continually opened itself? thought would be good to better my knowledge of these things or is it just an 'unexpected error' type thing. Link to comment Share on other sites More sharing options...
AdamUL Posted November 5, 2013 Share Posted November 5, 2013 (edited) Your welcome. I'm not sure, I cannot see were you are executing the EXE or the script more then once. I do have a question. Is netterm.exe a console application? Never mind, I looked it up, and it is not. Edited November 5, 2013 by AdamUL Link to comment Share on other sites More sharing options...
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