我想创建启动程序的批处理文件,20分钟后将关闭程序并重新启动它。
我对批处理文件的唯一了解是如何启动程序:
@echo off
Start [adress of application]
答案 0 :(得分:14)
这有效:
@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
答案 1 :(得分:6)
@echo off
:loop
start yourtarget.exe ...
timeout /t 1200 >null
taskkill /f /im yourtarget.exe >nul
goto loop
应该做的。
答案 2 :(得分:0)
对于遇到这个老问题的人: 您也可以ping到一个绝对不存在的地址,而不是timeout.exe:
ping 999.199.991.91 -n 1 -w 60000 >NUL
您可以将60000更改为您想要的任何延迟(以毫秒为单位)。
1 second = 1000
10 seconds = 10000
60 seconds = 60000
等等..
答案 3 :(得分:-1)
@echo off
:loop
timeout /t 20 >null ( Wait for 20 seconds before kill program)
taskkill /F /IM terminal.exe
timeout /t 3600 >null ( wait for 1hr before returning to loop or recycle the process)
goto loop
我使用另一个名为mt4bar的程序来监视我的应用程序,并在它们崩溃或关闭时重新启动它们