Jump to content
Sign in to follow this  
potitpanda

How to kill and restart my script

Recommended Posts

potitpanda

Hello Everybody

I Want Script to Kill and restart it after clicking on Yes in a MSGBOX

How to do this ?

Edited by potitpanda

Share this post


Link to post
Share on other sites
Andreik

Use this function

Func Restart()
    If @Compiled = 1 Then
        Run( FileGetShortName(@ScriptFullPath))
    Else
        Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
d4rk

$path=@ScriptFullPath
run($path)
exit


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites
FreeRider

Hello potitpanda

I know you already had some answers... But as I already needed to do the same as you want to, I developed a short function which allows me to update "myself" and restart the application.

If you just want to perform a restart modify the script below and replace the "To be removed" line by something which would make the script to loop until the application stops.

Ex : When the application starts an Text file is generated and when it shuts down this file is deleted. Of course the "@ScriptFullPath" must be replaced by the full path to the text file.

Func Restart($FileToRename,$NewFileName,$Restart)
    $SC_File = @TEMPDIR & "\automaj.bat"
    FileDelete($SC_File)
    $SC_batch = 'loop:' & @CRLF & _
    'del "' & @ScriptFullPath & '"'  & @CRLF & _; <<<<<< To be removed
    'if exist "' & @ScriptFullPath & _ 
    '" goto loop' & @CRLF & _
    'ren "'  & $FileToRename & '" ' & $NewFileName & @CRLF & _
    'del "' & $FileToRename & '"'  & @CRLF
    If $Restart = "YES" Then $SC_batch = $SC_batch & '"' & @ScriptFullPath & '" ' & '"' & "RESTART" & '"' & @CRLF
    $SC_batch = $SC_batch & 'del automaj.bat' & @CRLF
    FileWrite($SC_File,$SC_batch)
    Run($SC_File,@TEMPDIR,@SW_HIDE)
    Exit
EndFunc

Salut Camarade,

FreeRider


FreeRiderHonour & Fidelity

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  

×