DW1 Posted June 19, 2007 Share Posted June 19, 2007 I know that this is sloppy. I have written a script for work that detects when a certain program stops functioning. Currently I am using a simple pixle test on a blinking light in the program. The light stops blinking and I know that the program has stopped. There are no error messages upon crash, and no noticeable change except nothing updates anymore, including the blinking light. There must be a smarter way to detect a program/process crash. any advice would be great P.S. I know that the way I am writing the log sucks LOL ( but its only for work and I was in a hurry LMAO ) thanks in advance CODE$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 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Valuater Posted June 19, 2007 Share Posted June 19, 2007 maybe... Global $Process = "notepad.exe" ;********* for testing Run("notepad.exe") WinWaitActive("") Send("Please close this notepad", 1) ;********* While 1 If Not ProcessExists($Process) Then MsgBox(0x0, "Notice", $Process & " is no longer running", 5) Exit EndIf Sleep(10) WEnd 8) Link to comment Share on other sites More sharing options...
DW1 Posted June 19, 2007 Author Share Posted June 19, 2007 the process does not close when the program crashes, that is the issue. The process is still running. So to re phrase the question; how can you detect the crash of a program that doesn't stop its process when it fails, also there is no popup dialog box or any warning. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted June 19, 2007 Author Share Posted June 19, 2007 (edited) is the pixel test the only way to do this? toady? come on HHHHHHEEEEEEEEEEELLLLLLLLLLLLLPPPPPPPPPP Edited June 19, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted June 19, 2007 Author Share Posted June 19, 2007 sorry for bumping this to the top, but I am at work and almost out of lunch time AutoIt3 Online Help Link to comment Share on other sites More sharing options...
/dev/null Posted June 19, 2007 Share Posted June 19, 2007 the process does not close when the program crashes, that is the issue. The process is still running. So to re phrase the question; how can you detect the crash of a program that doesn't stop its process when it fails, also there is no popup dialog box or any warning.there is no way to detect that. __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
DW1 Posted June 19, 2007 Author Share Posted June 19, 2007 is there a way to monitor CPU/Ram usage of the process? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
/dev/null Posted June 19, 2007 Share Posted June 19, 2007 is there a way to monitor CPU/Ram usage of the process? try this: $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process") For $objItem in $colItems ConsoleWrite("Name: " & $objItem.Name & @CRLF) ConsoleWrite("PercentProcessorTime: " & $objItem.PercentProcessorTime& @CRLF) ConsoleWrite("PercentUserTime: " & $objItem.PercentUserTime& @CRLF) Next Use the value of _Total to calculate the "real" percentage of each process. __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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