akorx

Keep a program alive

9 posts in this topic

#1 ·  Posted (edited)

Hi my friends !

Sometimes, I've not find the reason why, my program (a compliled script) stops working (crash) without error... Is there a way to keep it alive with something like this "on error do nothing" (I've time to find the reason before few weeks) ?

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites



Yes, remove the root problem. 

Honestly. Make your program more reliable so you won't need a 'trick' to restart it after a crash. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Nothing like "on error" ?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Not easy to advise without seeing your code. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can use OnAutoItExitRegister (at the beginning of your code), then you will know if you script ends due to a crash or a logical exit.

Example :

OnAutoItExitRegister("_OnExitFunc")

; You code....

Func _OnExitFunc()
    MsgBox(48, "", "Exiting script...")
EndFunc

With this code, if the MsgBox appears, then if is not due to a crash but a bad scripting... In this case you can use ShellExecute(@ScriptFullPath) in the _OnExitFunc function to relaunch your script (but it would be really better to determine cause of the exit instead)

Edit : as Water said, show your code...

Edited by jguinch

Share this post


Link to post
Share on other sites

The function is not called when the script crashes. Check @exitMethod for the supported methods to exit the script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

First, thanks for yours replies guys !

I haven't got the script here because it's on computer at work... but it has no "exit" because it runs every time, like an antivirus program. Endeed, it's a program to tile windows, fixe others at the top, etc.

I can imagine that the crash of my program appears when I want to resize a window that is not responding (but his process is still there). We can understand behind this, that it's NOT a "normal case". A "normal case" is : the process exists or it doesn't exist, we can verify his state before running the function (resize for example). A zombie process or a process that is not responding is NOT a "normal case". You understand :blink: ?

So I suppose that we can find a function "ON ERROR" that stops the resize function when it happens in order to keep my program alives, but how can we do this with autoit?

PS : sorry for my bad english, I'm french.

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Your english is not so bad :)

First, I suggest you to post your code here as soon as you can : I'm pretty sure that someone will point out why you script fails.tI

To find out the issue by yourself, you can add an ouput comment per line (to the console or a log file). If you can reproduce the problem with the non-compiled script, look at the Trace: Add trace line feature on Scite, it should be usefull to find the faulty line.

Il y a plein de français par ici... ^_^

 

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