Sign in to follow this  
Followers 0
bittware

Command that could restart program from very beginning

4 posts in this topic

Hello experts,

In my application, I want an operation that could reset the program and then let the program starts running from the very beginning. Is there any such command in AutoIt? Thanks.

BRs,

bittware

Share this post


Link to post
Share on other sites



Hey,

Perhaps you could just restart the whole script?

Func _SelfRestart() ; restart the app
    Local $iMsgBoxAnswer = MsgBox(308, "Restarting...", "Are you sure you want to restart?")
    If $iMsgBoxAnswer <> 6 Then Return ; Not Yes so return
    If @Compiled Then
        Run(FileGetShortName(@ScriptFullPath))
    Else
        Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc   ;==>_SelfRestart

Share this post


Link to post
Share on other sites

The clean, structured way would be to create a function to reset/clear your variables and arrays, and use a loop to go back to the top of your code.

Other than that, there are likely a million cheesy ways, here's one of them:

#include <Misc.au3>
#include <Date.au3>

If _Singleton (@ScriptName, 1) = 0 Then ; If process is already running, kill older process
;   WinClose("yoohoo")
    ProcessClose(@ScriptName)
EndIf
$response = MsgBox(1,"yoohoo",_Now())
If $response = 1 Then Run(@ScriptFullPath) ; restart script

Share this post


Link to post
Share on other sites

Hey,

Perhaps you could just restart the whole script?

Func _SelfRestart() ; restart the app
    Local $iMsgBoxAnswer = MsgBox(308, "Restarting...", "Are you sure you want to restart?")
    If $iMsgBoxAnswer <> 6 Then Return ; Not Yes so return
    If @Compiled Then
        Run(FileGetShortName(@ScriptFullPath))
    Else
        Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc   ;==>_SelfRestart

That is exactly what I want. A straightforward way

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