Sign in to follow this  
Followers 0
Chris86

Detect script crash?

11 posts in this topic

How can i detect if my script crashes or something?

Share this post


Link to post
Share on other sites



Well thats easy, when it "crashes" it will show some sort of warning/msgbox.

.. but I have the feeling you were not looking for this answer. :P


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

How can i detect if my script crashes or something?

If you do not fit OnAutoItExit(), try to write a second script that will monitor the crash of the first script, for example, using the ProcessExists().

while 1
    if not ProcessExists('MainScript.exe') then
        MsgBox(16, 'Error', 'MainScript.exe crashed!')
        exit
    endif
    Sleep(10)
wend

Share this post


Link to post
Share on other sites

Is it possible to have something in the script that doesn't need a another program to determine if the mainscript fails?

I need this for bug reporting on my website :P

Share this post


Link to post
Share on other sites

Is it possible to have something in the script that doesn't need a another program to determine if the mainscript fails?

I need this for bug reporting on my website :P

If your script is crashed (it is not in memory), what program do you think should record the event? If you do not like the second program can use the RegRead() and RegWrite() functions.

Share this post


Link to post
Share on other sites

If you have proper bug catching and reporting you won't have to worry about a crash because you'll already know. I think you just need to add in some error checking into your script, and you'll be golden.

Regards,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@JSThePatriot - You can't account for everything. I consider it a crash if somebody uses taskmanager to end the process. There is no way to add that error checking to your script.

Make a helper script like this

$return = RunWait("yourprog.exe"))

If $return = 0 Then
    MsgBox(0,"","Script exited normally")
Else
    MsgBox(0,"","Script crashed")
EndIf

Most programs/scripts will return 0 as success, just make sure that yours does the same.

Edit: Just reread

Is it possible to have something in the script that doesn't need a another program to determine if the mainscript fails?

. My solution doesn't, but by using Fileinstall() you could only have one exe. Edited by Prab

Share this post


Link to post
Share on other sites

I find another way then :P

Share this post


Link to post
Share on other sites

Edit: Just reread . My solution doesn't, but by using Fileinstall() you could only have one exe.

You can use 1 script to do both tasks. I am doing a similar thing in AutoIt3Wrapper which is always running 2 times when you hit compile.

One will monitor the version doing the actual compile and do a cleanup when the compile is canceled by the "Tools/Stop Executing"

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@JSThePatriot - You can't account for everything. I consider it a crash if somebody uses taskmanager to end the process. There is no way to add that error checking to your script.

Make a helper script like this

$return = RunWait("yourprog.exe"))

If $return = 0 Then
    MsgBox(0,"","Script exited normally")
Else
    MsgBox(0,"","Script crashed")
EndIf

Most programs/scripts will return 0 as success, just make sure that yours does the same.

Edit: Just reread . My solution doesn't, but by using Fileinstall() you could only have one exe.

I believe the end process would still try to call the OnAutoItExit function that can be specified through the options. Then I would recommend using Jos' method to preform any other tasks that a "second" script would perform.

Thanks,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Try this.

#NoTrayIcon

if ($CmdLine[0] > 0) and ($CmdLine[1] = '/run') then
    _RunScript()
else
    local $ExitCode = ShellExecuteWait(@ScriptFullPath, '/run', @ScriptDir)
    if not @error then
        switch $ExitCode
            case 0
                MsgBox(0, 'Report', 'The script has finished work successfully.')
            case else
                MsgBox(0, 'Report', 'The script is crashed!')
        endswitch
    else
        MsgBox(0, 'Report', 'Error when calling the "ShellExecute" function!')
    endif
    exit
endif

func _RunScript() ; This is your code
    if MsgBox(36, 'YourProg', 'Your script is running. Press "Yes" to crash this script or "No" to normaly exit.') = 6 then
        DllCall('kernel32.dll', 'int', 'FatalExit', 'int', 1)
    else
        exit
    endif
endfunc; _RunScript

Share this post


Link to post
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
Sign in to follow this  
Followers 0