Sign in to follow this  
Followers 0
jvanegmond

Reboot Script

7 posts in this topic

#1 ·  Posted (edited)

I'm looking for a way to make the script restart itself.. in stead of using 2 files that run each other and close themselves..

Something like EnvUpdate () but then AutoItScriptUpdate()

Edited by Manadar

Share this post


Link to post
Share on other sites



I'm looking for a way to make the script restart itself.. in stead of using 2 files that run each other and close themselves..

Something like EnvUpdate () but then AutoItScriptUpdate()

Manadar,

This worked for me to restart a compiled script (.exe)

If PrgName.exe is running, and it calls _Restart_Prg(), it restarts.

I hope this helps.

taurus905

Func _Restart_Prg() ; Restart Program

Run("PrgName.exe")

WinClose("PrgName")

EndFunc ; ==> _Restart_Prg


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Manadar,

This worked for me to restart a compiled script (.exe)

If PrgName.exe is running, and it calls _Restart_Prg(), it restarts.

I hope this helps.

taurus905

Func _Restart_Prg() ; Restart Program

Run("PrgName.exe")

WinClose("PrgName")

EndFunc ; ==> _Restart_Prg

Thanks taurus,

I changed WinClose("PrgName") for ProcessClose('PrgName.exe') and then it worked.

[edit] I figured by using Exit in stead of WinClose you get a bit more security. So i used Exit now.

Edited by Manadar

Share this post


Link to post
Share on other sites

Manadar,

I will try changing WinClose("PrgName") to ProcessClose('PrgName.exe')

It makes better sense.

Thanks. :think:

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

I thougth the task at hand was to restart the running script? As in restart PrgName from PrgName?

If that is the case, I think you should locate the PID of PrgName before starting new PrgName, and then close the PID. Othervice you could be closing the PrgName you just started :think:

Share this post


Link to post
Share on other sites

I thougth the task at hand was to restart the running script? As in restart PrgName from PrgName?

If that is the case, I think you should locate the PID of PrgName before starting new PrgName, and then close the PID. Othervice you could be closing the PrgName you just started :think:

Uten,

I agree with all you said. And I knew there had to be a better way, because I was restarting another instance before I closed the first one. I felt it was a timing issue and that's why it worked. Not sure. :">

I was just glad that it worked without any bad side-effects, that I knew of.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

#Region --- Restart Program ---
    Func _RestartProgram(); Thanks UP_NORTH
        If @Compiled = 1 Then
            Run(FileGetShortName(@ScriptFullPath))
        Else
            Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
        EndIf
        Exit
    EndFunc; ==> _RestartProgram
#EndRegion --- Restart Program ---


Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

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