I want to create batch file which starts a program and after 20 minutes will close the program and start it again.
The only thing I know about a batch file is how to start a program:
@echo off
Start [adress of application]
Step 1: Make the Batch File Click the right mouse button, hover over "New", and click "Text Document". Give it the name you want the command to be called (restart), followed by . bat (restart.
Press Win+I to open Windows Settings. Go to Accounts > Sign-in options. Find the Automatically save my restartable apps and restart them when I sign back in setting. Toggle the respective button to turn it on.
When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.
You can insert the pause command before a section of the batch file that you might not want to process. When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.
@echo off
:loop
start yourtarget.exe ...
timeout /t 1200 >null
taskkill /f /im yourtarget.exe >nul
goto loop
should do the job.
This works:
@echo off //Turn off screen text messages
:loop //Set marker called loop, to return to
start "Wicked_Article_Creator" "C:\Wicked Article Creator\Wicked Article Creator.exe" //Start program, with title and program path
timeout /t 1200 >null //Wait 20 minutes
taskkill /f /im "Image Name" >nul //Image name, e.g. WickedArticleCreator.exe, can be found via Task Manager > Processes Tab > Image Name column (look for your program)
timeout /t 7 >null //Wait 7 seconds to give your prgram time to close fully - (optional)
goto loop //Return to loop marker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With