I would like to use batch file to check if a .exe is running and if it is, set a ping for say 30 seconds and recheck endlessly. If the .exe is not running then start another .bat file and then check again on a constant loop with out user action needed.

I have checked many pages here and tried many things and cant seam to get anything to work. so ill give more details. 

I need this .bat file once started to check in see if "7dtd.exe" is running, if it is running then wait, i have see the whole ping null thing as a timer for about 30 seconds, and then recheck if "7dtd.exe" is running. if it is not running then i need it to start a separate "startdedi.bat" file and then check for the same "7dtd.exe" and continue to check endlessly. Any help would be great!

startdedicated.bat

```
@echo off
rem Starts a dedicated server
rem
rem -quit, -batchmode, -nographics: Unity commands
rem -configfile           : Allows server settings to be set up in an xml config file. Use no path if in same dir or full path.
rem -dedicated                    : Has to be the last option to start the dedicated server.

set LOGTIMESTAMP=

:: --------------------------------------------
:: REMOVE OLD LOGS (only keep latest 20)

for /f "tokens=* skip=19" %%F in ('dir 7DaysToDieServer_Data\output_log*.txt /o-d /tc /b') do del 7DaysToDieServer_Data\%%F

:: --------------------------------------------
:: BUILDING TIMESTAMP FOR LOGFILE

:: Check WMIC is available
WMIC.EXE Alias /? >NUL 2>&1 || GOTO s_start

:: Use WMIC to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
    IF "%%~L"=="" goto s_done
    Set _yyyy=%%L
    Set _mm=00%%J
    Set _dd=00%%G
    Set _hour=00%%H
    Set _minute=00%%I
    Set _second=00%%K
)
:s_done

:: Pad digits with leading zeros
Set _mm=%_mm:~-2%
Set _dd=%_dd:~-2%
Set _hour=%_hour:~-2%
Set _minute=%_minute:~-2%
Set _second=%_second:~-2%

Set LOGTIMESTAMP=__%_yyyy%-%_mm%-%_dd%__%_hour%-%_minute%-%_second%

:s_start

:: --------------------------------------------
:: STARTING SERVER

echo|set /p="251570" > steam_appid.txt

start 7daystodieserver -logfile 7DaysToDieServer_Data\output_log%LOGTIMESTAMP%.txt -quit -batchmode -nographics -configfile=serverconfig.xml -dedicated

echo Starting server ...
timeout 15

cls

echo.
echo Server running in background, you can close this window.
echo You can check the task manager if the server process is really running.
echo.
echo.

pause

```

I tried this command out and it seams to be working the way i need it to

```
@echo off
cls
:start
@echo Starting 7DTD Dedicated Test Server...

7daystodieserver -logfile 7DaysToDieServer_Data\output_log%LOGTIMESTAMP%.txt -quit -batchmode -nographics -

configfile=serverconfig.xml -dedicated

echo.
for /F "tokens=2" %%i in ('date /t') do set mydate=%%i
set mytime=%time%
echo Restarting Test Server: %mydate%:%mytime%
echo.
goto start

```

as long as the command windows stays up when the server closes it restarts it and lets me know the time when the server closed. thanks again for everyone help, this was driving me crazy!!!