SO keeps telling me "Please add some context to explain the code sections (or check that you have no incorrectly formatted all of your questions as code). Why does it keep telling me this? I do have comments within the code which explain what each section does. After adding this paragraph, it seems to have allowed me to post.
REM Runs scva.exe if it is not running; kills process after dosbox.exe is terminated
tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
goto LoopStart
) else (
cd "%~dp0../"
start /min "" "scva.exe"
goto FirstCheck
)
:FirstCheck
REM Waits until dosbox.exe is started before continuing, so the script doesn't terminate prematurely
tasklist /FI "IMAGENAME eq dosbox.exe" 2>NUL | find /I /N "dosbox.exe">NUL
if "%ERRORLEVEL%"=="0" (
goto LoopStart
) else (
goto FirstCheck
)
:LoopStart
REM Exits script if scva.exe is manually terminated, otherwise, goes to CheckDOSBox
tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
goto CheckDOSBox
) else (
exit
)
:CheckDOSBox
REM Goes to LoopStart while dosbox.exe is running, otherwise, goes to Kill
tasklist /FI "IMAGENAME eq dosbox.exe" 2>NUL | find /I /N "dosbox.exe">NUL
if "%ERRORLEVEL%"=="0" (
goto LoopStart
) else (
goto Kill
)
:Kill
REM Sends command to terminate scva.exe while scva.exe is running, otherwise, exits script
tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
taskkill /IM scva.exe
goto Kill
)
exit