Sign in to follow this  
Followers 0
Xylo

Auto restarting an application over time

7 posts in this topic

Hey there,
I just started my adventure with AutoIT and well, I have a problem.

Basically, I need my program to do:
1. Start an application

2. Wait 13 minutes

3. Close the application

4. Do the following all the time (infinite loop)

My code for now is:

HotKeySet("{ESC}", "_Terminate")


   Func RunBot()
      While 1
      Local $iPID = Run("directory to my application")
      Sleep(780000)
      ProcessClose($iPID)
      WEnd
   EndFunc


Func _Terminate()
   Exit
EndFunc

RunBot()
MsgBox ($MB_OK, "program is running somehow", "this is proof that this works")

It does nothing. Even MsgBox doesn't show up.
Can someone kindly help me please?

Share this post


Link to post
Share on other sites



You need to add error checking to your script. Add a ConsoleWrite after your $iPID declaration, to ensure you get that far. Then perhaps another ConsoleWrite when you enter Sleep. You need to determine where the break is, before you can resolve the issue.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

The error checking with ConsoleWrite shows me that everything is fine. It's just that the program doesn't start. Destination is all good, as I have checked that. 
The directory is : D:folder1folder2Application.exe

Share this post


Link to post
Share on other sites

So if you comment everything else out and just do

$iPID = Run(<path to app>)

does it work?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Unfortunately, no.

Share this post


Link to post
Share on other sites

What is the program? What if you use ShellExecute rather than run?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

That works :D 
Thank you very much for help! 

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