jorgeng Posted October 23, 2007 Posted October 23, 2007 Hello. Three years ago i did this autoit-script but it doesn't work as intended. My intention is to have the script in autostart and that it will check the file nntermin.log if it isn't updated in four minutes and then kill the process fbinet.exe - two files named exactly the same and then start the program with some parameters. For some reason it restart fbinet.exe every four minute, anyone knowing what's wrong? ; Kontrollerar om filen nnlog.termin uppdaterats senaste 4 minuterna, om ej omstart Friendly Börs ; 2004-03-22 - Jorgeng Sleep ( 420000 ) $I = 1 While $I < 2 ; Scriptet körs Måndag-Fredag kl.09.30-17.30 när börsen är öppen If @WDAY = 2 Or @WDAY = 3 Or @WDAY = 4 Or @WDAY = 5 Or @WDAY =6 Then ; If @HOUR >= 9 And @MIN > 30 Then ; If @HOUR < 18 And @MIN < 30 Then $t = FileGetTime("D:\Program\FriendlyBörsActiveTrader\nntermin.log", 2) If Not @error Then $filetime=$t[4]+($t[3]*60)+($t[2]*60*24)+($t[1]*30*24*60)+($t[0]*365*24*60) $time=@min+(@hour*60)+(@mday*60*24)+(@mon*30*24*60)+(@year*365*24*60) If $time > $filetime + 2 Then MsgBox(0, "Omstart","Friendly Börs startas om - Nntermin.log ej uppdaterad på 4 minuter",5) If Not @error Then ProcessClose("FBINET.EXE") Sleep ( 2000 ) EndIf If Not @error Then ProcessClose("FBINET.EXE") EndIf If Not @error Then Sleep ( 5000 ) Run("D:\Program\FriendlyBörsActiveTrader\FBINET.EXE /X /P256", "D:\Program\FriendlyBörsActiveTrader\", @SW_MAXIMIZE) EndIf Endif EndIf ; Endif ; Endif Endif Sleep ( 120000 ) Wend
PsaltyDS Posted October 23, 2007 Posted October 23, 2007 Take advantage of the Date.au3 UDF, and it comes out much easier to read (can't test - may have to tweak): #include <Date.au3> $sExeDir = "D:\Program\FriendlyBörsActiveTrader\" $sExeFile = $sExeDir & "FBINET.EXE" $sLogFile = "D:\Program\FriendlyBörsActiveTrader\nntermin.log" While 1 If @WDAY >= 2 And @WDAY <= 6 Then ; Get time stamp of log file $t = FileGetTime($sLogFile, 2) ; 2 = accessed If Not @error Then ; Format string to "YYYY/MM/DD hh:mm:ss" $filetime = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] ; Test age of log file If _DateDiff("n", $filetime, _NowCalc()) >= 4 Then ; "n" = diff in minutes ; log file older than 4min - Close all instances of "FBINET.exe" While ProcessExists("FBINET.EXE") ProcessClose("FBINET.EXE") Sleep(250) WEnd ; Start new instance of program Sleep(5000) Run($sExeFile & " /X /P256", $sExeDir, @SW_MAXIMIZE) EndIf EndIf EndIf Sleep(10000) ; Check every 10sec WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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