Sign in to follow this  
Followers 0
underfenix

Restar program every 5 Seconds

15 posts in this topic

#1 ·  Posted (edited)

Hi m8´s, im trying making this litle program but im with some problems.

I want a script that restart a program every 5 seconds.

Im waiting for some Help, thanks for all. :mellow:

Ric

Edited by underfenix

Share this post


Link to post
Share on other sites



Why is not possible?

Is only a Batch file m8 :mellow:

thanks by the answer

Share this post


Link to post
Share on other sites

When i run the script, will open the batch file, then close the batch file after 5 seconds, and repeat this process forever :mellow:

Share this post


Link to post
Share on other sites

help me please :mellow:

Share this post


Link to post
Share on other sites

Have a look at the documentation of

While <expression>
    statements
    ...
WEnd

and

Sleep
.

And if you want more detailed help, people might want to know what you want to do this for.

5 seconds sound like a short time for many tasks, so just in case - asking about help to trick in a game is at least frowned upon, more likely forbidden on this site, depending on the game.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi, i whant this program to restart a batch file, that control a printer, some times the batch file dont find the printer thats the problem.

i made this code but im having problems...

while
Run("C:\ASS_L\program.EXE")
ProcessClose("program.EXE")
Sleep(5000)
Run("C:\ASS_L\program.EXE")
ContinueLoop
WEnd
Edited by underfenix

Share this post


Link to post
Share on other sites

I see a few problems with your script:

while
Run("C:\ASS_L\program.EXE")
ProcessClose("program.EXE") ;this closes the process as soon as it starts
Sleep(5000)
Run("C:\ASS_L\program.EXE") ;you're not closing the program you're starting here
ContinueLoop ;Continueloop basically starts the loop from the top again. Your loop is going to do this anyways as it has reached the end.
WEnd

Try this:

while
$PID = Run("C:\ASS_L\program.EXE")
Sleep(5000)
ProcessClose($PID) ;using the $PID ensures that you close the program you just opened and not one that might have the same name.
WEnd

For future reference "i made this code but im having problems..." will ususally not be enough information to help you. You'll need to explain what it does and what you expect it to do aswell as any error messages if any.

Share this post


Link to post
Share on other sites

You are talking about batch files but you are calling .exe files. :mellow:

While 1
    $run = Run(@ComSpec & " /c " & "C:\Test.cmd")
    Sleep(5000)
    If ProcessExists($run) Then ProcessClose($run)
WEnd

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Provided you app outputs an exitcode it could be as simple as this.

Do
    $exitcode = RunWait("C:\ASS_L\program.EXE")
    Sleep(5000)
Until $exitcode = ;sucsessful exit code of your exe here
Edited by JohnOne

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

My ideia is....

If the application is running, then whait 5 seconds then close application, and open application again, Or if appliacation is not runing, open apllication, whait 5 seconds, close application and open again and repeat this processe allways restarting the application every 5 seconds closing and open.

Im working on it i will place some code, to everyone see if is correct

Thanks for all help m8´s

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Well m8´s with the help of many good people the problem is solved.

Anyone know why when i make the window hide it allways flash when restart the program???

Here is the code:

While 1
    $run = run ("C:\Application.exe")
    WinWait("Advanced IP Scanner v1.5")
    WinSetState("Advanced IP Scanner v1.5","",@SW_HIDE) 
    Sleep(9000)
        If ProcessExists($run) Then ProcessClose ($run)
WEnd

Thanks m8´s

Edited by underfenix

Share this post


Link to post
Share on other sites

Because you run the application, resulting in a visible window, which you then hide.

Specify @SW_HIDE as a parameter for the initial run(), so the window is never made visible.

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