Search code examples
batch-filerestart

Script to restart a program every few minues


I've tried restarting a program every few minutes with a batch file which looks like the following. However it only opens the .exe a lot of times which causes them to crash. Anyone knows why this problem occurs?

@echo off                           
:loop                               
start "programm" "D:\Downloads\programm.exe"  
timeout /t 1200 >null               
taskkill /f /im "programm" >null    
timeout /t 7 >null                  
goto loop                          

Solution

  • I hate a short answer, but it's an easy and quick fix. null is nothing, use nul as it's almost certainly skipping the invalid output name.

    So the code:

    @echo off
    :loop
    start "programm" "D:\Downloads\programm.exe"  
    timeout /t 1200 >nul
    taskkill /f /im "programm" >nul
    timeout /t 7 >nul
    goto :loop