Scheduled task returns 0xFF, but works ok
Try adding an exit 0
as the last statement in the batch file.
Quits the CMD.EXE program (command interpreter) or the current batch
script.
EXIT [/B] [exitCode]
/B specifies to exit the current batch script instead of
CMD.EXE. If executed from outside a batch script, it
will quit CMD.EXE
exitCode specifies a numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number.
Hmm ... I'm not sure of the exact semantics of the call {:label}
command or how it "returns" - if your :go_now
subroutine is returning normally (i.e., processing more than one file) when you don't put an end
or exit
there, then don't do that.
Probably need to change this
if %%a not==("*.mpg") goto eof
to
if %%a not==("*.mpg") exit 0
but I bet the reason why it's returning 0xFF
is because goto eof
is a syntax error, you wanted to write goto :EOF
.
Related videos on Youtube
SamAstin
Updated on September 18, 2022Comments
-
SamAstin over 1 year
The batch file converts mpg to avi and runs on a schedule. Although the batch works ok from the schedule, Scheduled Task returns the 0xff message. Running manually, it displays an exit code of 0. I tried inserting 'end' - which gives a return of 0x0, but it only converts the first file and ignores the rest.
del /q /s staxrip_temp\* cd staxrip_temp for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d" cd.. for %%f in (*.mpg) do echo %%f for %%a in ("*.mpg") do call :go_now "%%a" if %%a not==("*.mpg") goto eof :go_now echo processing %~n1.mpg staxrip.exe -template:_myxvid "%~dpn1.mpg" -encode -exit del /q "%~dpn1.mpg" rem echo %ERRORLEVEL% rem end
Resolved: Replaced if %%a not==("*.mpg") goto eof with: if not exist %%a%% exit
-
SamAstin almost 11 yearsAdding exit 0, only the first file is processed, then it exits.
-
SamAstin almost 11 yearsif not exist %%a%% exit works, goto :EOF doesn't, neither does if %%a not==("*.mpg") exit 0