Jump to content

Process.Responding Property (System.Diagnostics)


 Share

Recommended Posts

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:

$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 by danwilli
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :rolleyes:

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 by FreeFry
Link to comment
Share on other sites

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 by danwilli
Link to comment
Share on other sites

LOL okay xD

I'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 by FreeFry
Link to comment
Share on other sites

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. :rolleyes:

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 by FreeFry
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...