I tired this code below.
Code: Select all
@echo off
cls
echo App started.
call "ape.bat"
cls
echo WARNING: App closed or crashed!
pause
exit
Thanks for reading and have a good day!
Moderator: DosItHelp
Code: Select all
@echo off
cls
echo App started.
call "ape.bat"
cls
echo WARNING: App closed or crashed!
pause
exit
Code: Select all
@echo off
pause
Code: Select all
@echo off &setlocal
for /f %%i in (
'powershell.exe -nop -ep Bypass -c "$p=Start-Process -Wait -PassThru -FilePath 'C:\Windows\system32\cmd.exe' -ArgumentList '/c','\"\"test.bat\"\"';$p.ExitCode;"'
) do echo exitcode: %%i
pause
Code: Select all
@echo off
pause
Code: Select all
@echo off
pause
start /k me.bat
Code: Select all
TITLE Watchdog
CLS
@ECHO OFF
set batch1=test1.bat
set batch2=test2.bat
:startwatch
::CLS
ECHO.
ECHO --------------------Starting watchdog--------------------
ECHO.
set BatchPath="%~dp0"
call:run %batch1%
call:run %batch2%
goto:eof
:run
ECHO.
CLS
ECHO --------------------Starting app--------------------
ECHO.
CD %BatchPath%
for /f %%i in (
'powershell.exe -nop -ep Bypass -c "$p=Start-Process -Wait -PassThru -FilePath 'C:\Windows\system32\cmd.exe' -ArgumentList '/c','\"\"%~1\"\"';$p.ExitCode;"'
) do echo exitcode: %%i & set code=%%i
if %code% == 1 goto problem
if %code% == 0 goto good
:good
ECHO.
ECHO. Everything went ok with %~1.
ECHO. Everything went ok with %~1.>%~1.log
ECHO.
goto:eof
:problem
ECHO.
ECHO. Something went wrong with %~1. Please investigate the cause.
ECHO. Something went wrong with %~1. Please investigate the cause.>%~1.log
ECHO.
goto:eof
:eof
exit
Code: Select all
@echo off
if not exist tmp.tmp exit
del tmp.tmp
echo uh no...
echo.
echo looks like the file you were trying to run exited unexpectedly..
pause
exit
Code: Select all
createobject("wscript.shell").run""""& wscript.arguments(0) &"""",0,false
Code: Select all
@echo off
set /p name=<filname.txt
start %name%
if not exist %name% exit
echo .>tmp.tmp
wscript.exe "invis.vbs" "watchdog.bat"
exit
Code: Select all
@echo off
if not exist tmp.tmp exit
del tmp.tmp
SETLOCAL EnableExtensions
if not exist filname.txt goto nofil
if exist filname.txt set /p filname=<filname.txt
:loop
set EXE=%filname%
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND
goto FIN
:FOUND
echo Running
goto loop
pause
:FIN
:nofil
echo .>tmp.tmp
start error.bat
exit
Code: Select all
@echo off
setlocal
If /i [%1] == [APE] goto :APE
::__________________________________
::
:: WATCHDOG
::__________________________________
::
TITLE Do not close this!!
Echo this is the watchdog routine. Don't close this.
start /w "RUN APE" "%~f0" APE
Echo APE is no longer running (exited with exit code %ERRORLEVEL%). Do some stuff here
pause
goto :EOF
::__________________________________
::
:APE
::__________________________________
::
Echo this is APE
echo Press a key to exit the APE routine with exit code 5
pause
exit 5
goto :EOF