Yashied

Restart UDF

17 posts in this topic

#1 ·  Posted (edited)

LAST VERSION - 1.0

07-Mar-10

This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions.

Restart UDF Library v1.0

Previous downloads: 943

Restart.au3

Example

#NoTrayIcon

#Include <Misc.au3>
#Include <Restart.au3>

_Singleton('MyProgram')

If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then
    _ScriptRestart()
EndIf
Edited by Yashied
3 people like this

Share this post


Link to post
Share on other sites



Nice Yashied. Very smart. Thank for sharing. :mellow:

Share this post


Link to post
Share on other sites

Very useful for me. thanks.


Share this post


Link to post
Share on other sites

Yes, Actually very useful.


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites

Cool,

just what I needed. I set up a tray menu based on modern menu from Holger.

For the menu I wrote a treeview based edit tool, which can handle the menu ini.

After editing the tray menu has to be restarted.

I just thought about it, so that it works for script and exe, as I saw this tool.

Works great and really easy to use - no changes, nothing complicated - only include and use.

If I find the stars button - you get it.

Best regards, Reinhard

Share this post


Link to post
Share on other sites

what i needed.... thanks :idea:


0x5748415420444F20594F552057414E543F

Share this post


Link to post
Share on other sites

LAST VERSION - 1.0

07-Mar-10

This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions.

Restart UDF Library v1.0

Restart.au3

Example

#NoTrayIcon

#Include <Misc.au3>
#Include <Restart.au3>

_Singleton('MyProgram')

If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then
    _ScriptRestart()
EndIf

many thanks.it's perfect!

Try to face everything troubles you.nothing is impossible!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

is it possible to make scite again the StdOut process for the script

So its possible to use ConsoleWrite

How to make this code write in the console

#NoTrayIcon
#Include <Misc.au3>
#Include <Restart.au3>
_Singleton('MyProgram')
If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then
_ScriptRestart()
ConsoleWrite('-> Restarted..!')
EndIf
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Your consolewrite is what is known as unreachable code, it will never get to that point.

You would need to add code, to indicate externally whether the script has been restarted.

And read it upon starting the script.

Of course upon exiting your script normally or via a crash you would need to reset whatever variable

you use, be that a text or ini file, or registry or whatever.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Yeah got it thanks

This works

#NoTrayIcon

#Include <Misc.au3>
#Include <Restart.au3>
_Singleton('MyProgram')
If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then
ConsoleWrite('-> Restarted..!')
_ScriptRestart()
EndIf

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#16 ·  Posted

Hi all,

thanks for this UDF, very usefull !

But sometimes, i encounter a problem :o:

My users run my program from the network :   \\myserver\share\program.exe

When i need to update my program, i replace my program.exe with a new version.  The name is still program.exe  but it is in version2 now (vesus version 1 before)

So i have overwritten my program.exe with a new program.exe, the version 1 does'nt exist anymore but users are still executing it.

When i restart my program, the users which where executing the version1 should be now in version 2 after restart.

But not always, sometimes some users remains with the version 1 :blink:, even severals days after it has been replaced. (Something which looks like a cache problem from windows).

=> I've looked your code: restart.au3 does this: run the exe, get the new PID, send the actuel PID to the new process, and send an exit. The new program wait until the old process die and then goes on.

In this way, we start the program, before killing the old one.   My 'cache' probleme may come from that.

 

do you have any idea for me ?

I know this is not an autoit problem but you have good ideas there ^^ o:)

thanks !

Nicolas.

Share this post


Link to post
Share on other sites

#17 ·  Posted

hi guys !

I reply to myself, but still got the problem.

So, i found another similar case today, i used process explorer to check location , path, etc of the executable being used and it indicate my network path.

Nothing that help me on that point.

I have to take the time to make a real stop and start, using a second distinct program. And i know i won't have the problem anymore...

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