DW1 Posted June 20, 2007 Share Posted June 20, 2007 (edited) I would like to use something like this ( http://msdn2.microsoft.com/en-us/library/s...responding.aspx ) instead of using a pixel test to detect the crash of a program whose process does not die on crash and gives no warning for the crash. The current script I am using works but as you can see is sloppy:expandcollapse popup$run = 1 ; for the while statement $color = 0 ; just needs to be declared $timeout = 30 ; seconds to timeout the restart $proc = "ResMan.exe" ; name of process to restart $runme = "\\spr1aprapppin01\aproposinstall\Resman6\resman.exe" ; name of exe to start on process kill $runindir = "C:\Program Files\Common Files\Apropos Shared" While $run = 1 If ProcessExists($proc) Then ;Do Nothing; run as usual Else MsgBox(0, "Error", "the " & $proc & " process is not running. Start it before starting this script") Exit EndIf $test = PixelGetColor(175, 50) If $test <> $color Then $color = $test $time = (@HOUR * 3600) + (@MIN * 60) + @SEC EndIf $ctime = (@HOUR * 3600) + (@MIN * 60) + @SEC If $ctime - $time > $timeout Then ;If it has been the specified timeout, this will trigger restart $info = "Crash detected - Script stopped: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) ProcessClose($proc) ;kill process $info = "Killed ResMan: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) $looping = 1 While $looping = 1 If ProcessExists($proc) Then ;loop Else $info = "Kill Successful: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) $looping = 2 EndIf WEnd Run($runme, $runindir) $info = "Starting ResMan again: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) WinWait("Apropos Resource Manager Version 6.5 Log On") ; wait for login screen WinActivate("Apropos Resource Manager Version 6.5 Log On") ; bring login to front Sleep(500) Send("{tab}") Sleep(500) Send("password") Sleep(500) Send("{enter}") $info = "Entered Password for attempt on start: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) Sleep(300000) ;Waits five minutes to start testing pixel again $time = (@HOUR * 3600) + (@MIN * 60) + @SEC $ctime = (@HOUR * 3600) + (@MIN * 60) + @SEC $info = "Script Active Again: " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "." & @MIN & "." & @SEC FileWrite("log.log", $info & @CRLF) EndIf WEnd Exit Edited June 20, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted June 20, 2007 Author Share Posted June 20, 2007 *bump* sry AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 What kind of process is it you're monitoring exactly? Link to comment Share on other sites More sharing options...
DW1 Posted June 20, 2007 Author Share Posted June 20, 2007 i am monitoring an internal program for the company I work for. I have it set up to run the specified program "ResMan.exe" which will display the queue/hold times for each tech support queue that we have ALL OVER THE WORLD. When that prog crashes it just stops updating, and the blinking icon I have been monitoring stops blinking. what info on the process do you need? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 I mostly thought if it was some kind of server which you could ping/connect to and see if it have hanged that way. Link to comment Share on other sites More sharing options...
DW1 Posted June 20, 2007 Author Share Posted June 20, 2007 it is sort of set up as a server, but the computer does not crash, thus a ping would run fine. I am running tightVNC so that everybody in the building here can view and quote hold times for tech support queues. The code at the top of the page works fine for what I want it to do.... it is just sloppy and unprofessional. If I were to put a window in front of the blinking icon, my program would kill the process every five minutes and restart it (which is why it is sloppy). I am looking for a solution that does not involve a pixel test. The link I supplied would work if I had a way to incorporate it into my autoit script. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 (edited) Hmm, if it's a server, then it will probably be listening to a port of some kind, and if that's the case, you probably could try and connect to the server and if it doesn't respond you know it has hanged.. probably Otherwise I think it would involve some DllCall thingy... :/Edit:Take a look @ UDPOpen and TCPConnect functions if you wanna have a go at the connect thingy.. Edited June 20, 2007 by FreeFry Link to comment Share on other sites More sharing options...
DW1 Posted June 20, 2007 Author Share Posted June 20, 2007 (edited) YES!!! that is what I want, is help with calling a DLL (like the one discussed here http://msdn2.microsoft.com/en-us/library/s...esponding.aspx) for a boolean respone to a process not responding. This DLL seems to be rather choosey on what a "non responsive" process is (AND THATS WHY I NEED IT LOL). In C++, while watching IE, if IE took too long to load a page, it would fail the boolean. Edited June 20, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 (edited) LOL okay xDI'll have a look at http://msdn2.microsoft.com/en-us/library/s...responding.aspx (though I'm not that good at DllCall)hmm, I don't think that can be used, as it's not a Dll, but a property .. thing.. I'm not that good with c++ but I think that you can't use that with autoit.. :S I'm gonna look into it a little bit more Edited June 20, 2007 by FreeFry Link to comment Share on other sites More sharing options...
FreeFry Posted June 21, 2007 Share Posted June 21, 2007 I couldn't find any function that could be used with DllCall to get the process status/responding thing. :/ Link to comment Share on other sites More sharing options...
DW1 Posted June 21, 2007 Author Share Posted June 21, 2007 thank you so much for taking the time to look into it anyway, I really do appriciate it. Thanks FreeFry AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FreeFry Posted June 21, 2007 Share Posted June 21, 2007 (edited) Sorry I couldn't help you out though. :/ I would take my guess that you're talking about some kind of server, and in that case, you could try and do a TCPConnect/UDPOpen to the server, and if it fails the server probably have hanged/crashed.. Best of luck to you mate. Edit: If the server software is something you don't like giving out info about you could PM me, and I might be able to help you further. Edited June 21, 2007 by FreeFry 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