18

我想创建一个启动程序的批处理文件,20分钟后将关闭程序并重新启动它。

关于批处理文件,我唯一知道的是如何启动程序:

@echo off
Start [adress of application]
4

4 回答 4

23

这有效:

@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
于 2014-05-14T09:59:48.553 回答
6
@echo off
:loop
start yourtarget.exe ...
timeout /t 1200 >null
taskkill /f /im yourtarget.exe >nul
goto loop

应该做的工作。

于 2013-03-24T19:46:53.670 回答
-1

对于遇到这个老问题的任何人:您还可以 ping 到一个绝对不存在的地址,而不是 timeout.exe:

ping 999.199.991.91 -n 1 -w 60000 >NUL

您可以将 60000 更改为您想要的任何延迟(以毫秒为单位)。

1 second = 1000

10 seconds = 10000

60 seconds = 60000

等等..

于 2013-10-09T16:49:01.527 回答
-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 的程序来监控我的应用程序,并在它们崩溃或关闭时重新启动它们

于 2019-04-02T11:03:45.253 回答