Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for %%P in (%executableList%) do (
- echo ----------------------------------------------------------------------------------
- set exeErrorlevel=0
- set running=false
- start %%~fP
- set exeErrorlevel=!ERRORLEVEL!
- rem for debugging purposes
- echo %%~nP%%~xP older errorlevel %ERRORLEVEL%
- echo %%~nP%%~xP newer errorlevel !ERRORLEVEL!
- echo before tasklist running var is : !running!
- tasklist /FI "IMAGENAME eq %%~fP" | find /I /N /C "%%~fP" >nul && set running=true
- echo after tasklist is running var is: !running!
- if !running! equ true (
- echo %%~nP%%~xP Program is running
- taskkill /F /IM %%~nP%%~xP /T
- echo %%~nP%%~xP Program was killed
- if !exeErrorlevel! == 0 (
- echo %passString% %%~nP%%~xP process was started and killed safely
- echo %passString% %%~nP%%~xP process was started and killed safely >>%outputfile%
- ) else (
- echo %failString% %%~nP%%~xP process was killed with errorcode !exeErrorlevel!
- echo %failString% %%~nP%%~xP process was killed with errorcode !exeErrorlevel! >>%outputfile%
- )
- ) else (
- if !exeErrorlevel! == 0 (
- echo %passString% %%~nP%%~xP process exited safely
- echo %passString% %%~nP%%~xP process exited safely >>%outputfile%
- ) else (
- taskkill /F /IM %%~nP%%~xP /T
- echo %failString% %%~nP%%~xP process abruptly exited with errorcode !exeErrorlevel!
- echo %failString% %%~nP%%~xP process abruptly exited with errorcode !exeErrorlevel! >>%outputfile%
- )
- )
- echo. >>%outputfile%
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement