Auto close and restart a program
Solution 1
Create a scheduled task using the task scheduler
tool. You can specify the start time (every 5 minutes) and set the "Stop task if it runs longer than" box at 5 minutes!
Create a trigger like this: on the scheduled task to start and stop the task.
Solution 2
You can do this using the free program autohotkey.
Essentially, you would create a loop consisting of opening the program, setting a timer for x minutes, then closing the program.
You will need to look at the following autohotkey commands:
You can also find useful snippets on SuperUser using the autohotkey tag.
Below is a very simple autohotkey script that would need minimal changes on your part to run what you're needing. Lines starting with a semi-colon are comments and can safely be removed:
; Below line keeps this script running until you close it
#Persistent
Loop
{
; Edit the below line to add your program
Run, C:\Program Files (x86)\Example Program\Example_Program.exe
;300000 on the line below is 5 minutes
Sleep, 10000
; Edit the below line to add your program's "Window Title"
; Note this is not the same as the program's name
WinClose, Example Program
}
Mike
Updated on September 18, 2022Comments
-
Mike over 1 year
I am looking for a way to automate the opening and closing of a program based on a timer.
What I am looking for would look like this:
- Open program
- Run program for 5 minutes
- Close program
- Do the above again and again
-
Werner Henze almost 11 yearsAs a software developer I must ask you: How about paying the developer for his work and so getting the full version without the limitations?
-
Austin T French almost 11 yearsWhy would you need to do this, unless @WernerHenze is correct. And then you should either pay up, or move on.
-
Werner Henze almost 11 years@AthomSfere: The original question (you can see it when clicking on Paul's "edited ... ago") was very different from what it looks like now. Mike explicitely talked about a program that only works for some time and that you need to pay if you want the full version.
-
Paul almost 11 yearsHe mentioned that the software developer stated on their website to do this as a workaround. Why? Yeah, I scratched my head on that too. But the actual question behind it was worth an answer, so I edited it to remove the moral aspect and leave the technical aspect of the question. i feel the question as it is now is what he was asking, and is within SU guidelines.