View Single Post
Old 23rd December 2015, 21:45   #20  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by StainlessS View Post
need to detect and return ERRORLEVEL from ffmpeg call
1. Detecting an error level: it's easiest if you only care if %errorlevel% is zero (success) or nonzero (failure)
Code:
[try something...]
if errorlevel 1 goto failed
[do stuff]
goto :EOF

:failed
@echo failed! try again!
pause
goto :EOF
"if errorlevel 1" is true if %errorlevel% is 1, OR GREATER

If you want the exact error level, it's harder. See this (robvanderwoude.com)

2. Returning an error level from a batch file:
Code:
exit /b 42
To test this, after you run the batch file, type:
Code:
echo %errorlevel%
EDIT AutoHotkey, AutoIt, C++, C# etc can run a process and store the exit code.

EDIT sorry, it's "if errorlevel 1" not "if %errorlevel% 1"

Last edited by raffriff42; 24th December 2015 at 02:31.
raffriff42 is offline   Reply With Quote