Re: Scheduled Task error code:The task completed with an exit code




"Teo Chee Yang" <TeoCheeYang@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FDD575C4-E76A-422C-A83E-423533E0324E@xxxxxxxxxxxxxxxx
i'm running this mailsend.cmd file in this job:

@ECHO OFF
FOR /F "TOKENS=2 DELIMS= " %%1 IN ('date /T') DO SET currentDATE=%%1
FOR /F "TOKENS=5 DELIMS= " %%2 IN ('type C:\Script\schedlgu\schedlgu.txt')
DO SET fileDATE=%%2
if exist filedate.txt del /q filedate.txt
echo %fileDATE% >filedate.txt
if exist concatdate.txt del /q concatdate.txt
for /f "tokens=1 delims=/" %%A in ('type filedate.txt') do set mm=%%A
echo %mm% >mm.txt
if %mm% LSS 10 copy /b zero.txt+mm.txt concatdate-mm.txt
trim /f:concatdate-mm.txt /r
if %mm% GEQ 10 echo %mm% >concatdate-mm.txt
trim /f:concatdate-mm.txt /r
for /f "tokens=2 delims=/" %%B in ('type filedate.txt') do set dd=%%B
echo %dd% >dd.txt
if %dd% LSS 10 copy /b zero.txt+dd.txt concatdate-dd.txt
trim /f:concatdate-dd.txt /r
if %dd% GEQ 10 echo %dd% >concatdate-dd.txt
trim /f:concatdate-dd.txt /r
for /f "tokens=3 delims=/" %%C in ('type filedate.txt') do set year=%%C
echo %year% >concatdate-yyyy.txt
trim /f:concatdate-yyyy.txt /r
copy /b

concatdate-mm.txt+separator.txt+concatdate-dd.txt+separator.txt+concatdate-y
yyy.txt concatdate.txt
del /q dd.txt
del /q mm.txt
del /q concatdate-mm.txt
del /q concatdate-dd.txt
del /q concatdate-yyyy.txt
del /q filedate.txt
if not exist concatdate.txt goto :ENDNOW
set /p concatDATE=<concatdate.txt
if "%concatDATE%" == "%currentDATE%" goto :MATCHED
goto :ENDNOW

:MATCHED
MAILSEND.exe -d xx.com -smtp xxxxx -t xxx@xxxxxx -f jobs@xxxxxx -sub
"Failed
Scheduled Job" < schedlgu.txt
exit

:ENDNOW
exit

it makes use of 2 exe file: mailsend.exe and trim.exe. Does the exit code
ff
indicates anything?

"Pegasus (MVP)" wrote:


"Teo Chee Yang" <TeoCheeYang@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:403A729A-9222-4F47-8383-304E58BF4F5E@xxxxxxxxxxxxxxxx
I have a scheduled job running mailsed.exe for mail notification every
1
hour. However, sometimes there are some error message in the
schedlgu.txt
log
file as follow:

"The task completed with an exit code of [ff]"

Mai i know what does exit code ff means? Where can i find the exit
code of
scheduled tasks?

The exit code is determined by the application you run,
not by the Task Scheduler. What exactly is it?




There are several problems with your batch file:
- You use overly complicated coding. Keep it simple - it
will be much easier to debug!
- You consistently fail to specify a drive and a path for your
auxiliary files. This is bad. Instead of writing
echo %fileDATE% >filedate.txt, you MUST write your code like so:
echo %fileDATE% >c:\filedate.txt (for example)
- You use two non-standard tools, trim.exe and mailsend.exe, but
you don't say where these tools reside. You MUST state this
in your batch file, e.g. like so:
c:\tools\trim.exe /f: c:\concatdate-mm.txt /r
- For the benefit of the administrators who come after you, you should
include a descriptive header in your batch file like so:
@echo off
goto Start
=========================================
This batch file will do this:
- ... (put your words here)
- ...
- ...
Prerequisites: c:\tools\trim.exe
c:\tools\mailsend.exe

26 February 2007 Teo Chee Yang
=========================================
:Start
set CurrentDate=%Date:~4%
etc.

I did not attempt to follow the logic of the batch file. If you still
have a problem, post your modified version and explain the
actual purpose of the batch file.


@ECHO OFF
FOR /F "TOKENS=2 DELIMS= " %%1 IN ('date /T') DO SET currentDATE=%%1
*** Replace with: set CurrentDate=%Date:~4%

FOR /F "TOKENS=5 DELIMS= " %%2 IN ('type C:\Script\schedlgu\schedlgu.txt')
DO SET fileDATE=%%2
*** Replace with:
FOR /F "TOKENS=5 DELIMS= " %%a IN ('type C:\Script\schedlgu\schedlgu.txt')
DO SET fileDATE=%%a

if exist filedate.txt del /q filedate.txt
*** Omit this line. It is not required.

echo %fileDATE% >filedate.txt
*** You must specify the exact file location, e.g.
echo %FileDate% > c:\FileDate.txt

if exist concatdate.txt del /q concatdate.txt
*** You must specify the exact file location.

for /f "tokens=1 delims=/" %%A in ('type filedate.txt') do set mm=%%A
*** Much simpler to write set mm=%date:~4,2%

echo %mm% >mm.txt
*** You must specify the exact file location.

if %mm% LSS 10 copy /b zero.txt+mm.txt concatdate-mm.txt
*** You must specify the exact file locations.

trim /f:concatdate-mm.txt /r
*** You must specify the exact file locations for trim.exe and
concatdate-mm.txt

if %mm% GEQ 10 echo %mm% >concatdate-mm.txt
*** You must specify the exact file location.

trim /f:concatdate-mm.txt /r
*** You must specify the exact file locations for trim.exe and
concatdate-mm.txt

for /f "tokens=2 delims=/" %%B in ('type filedate.txt') do set dd=%%B

*** Much simpler to write set dd=%date:~7,2%

echo %dd% >dd.txt

*** You must specify the exact file location.

if %dd% LSS 10 copy /b zero.txt+dd.txt concatdate-dd.txt

*** You must specify the exact file location.

trim /f:concatdate-dd.txt /r

*** You must specify the exact file locations for trim.exe and
concatdate-mm.txt

if %dd% GEQ 10 echo %dd% >concatdate-dd.txt

*** You must specify the exact file location.

trim /f:concatdate-dd.txt /r

*** You must specify the exact file locations for trim.exe and
concatdate-mm.txt

for /f "tokens=3 delims=/" %%C in ('type filedate.txt') do set year=%%C

*** Much simpler to write set year=%date:~10,4%

echo %year% >concatdate-yyyy.txt

*** You must specify the exact file location.

trim /f:concatdate-yyyy.txt /r
*** You must specify the exact file locations for trim.exe and
concatdate-year.txt

copy /b
concatdate-mm.txt+separator.txt+concatdate-dd.txt+separator.txt+concatdate-y
yyy.txt concatdate.txt
*** You must specify the exact file locations

del /q dd.txt
del /q mm.txt
del /q concatdate-mm.txt
del /q concatdate-dd.txt
del /q concatdate-yyyy.txt
del /q filedate.txt
*** You must specify the exact file locations for the above files.

if not exist concatdate.txt goto :ENDNOW
*** Much simpler to write
if not exist concatdate.txt goto :eof
*** Note that :eof is an inbuilt label.

set /p concatDATE=<concatdate.txt
if "%concatDATE%" == "%currentDATE%" goto :MATCHED
goto :ENDNOW

*** Much simpler to write
if not "%concatDATE%" == "%currentDATE%" goto :eof

:MATCHED
MAILSEND.exe -d xx.com -smtp xxxxx -t xxx@xxxxxx -f jobs@xxxxxx -sub "Failed
Scheduled Job" < schedlgu.txt
*** You must specify the exact file locations for the above files.

*** Delete the remaining lines - you don't need any of them.
exit
:ENDNOW
exit



.



Relevant Pages

  • Re: Scheduled Task error code:The task completed with an exit code
    ... picked up a few advanced skills in batch file programming! ... if exist concatdate.txt del /q concatdate.txt ... You consistently fail to specify a drive and a path for your ... *** You must specify the exact file locations. ...
    (microsoft.public.windows.server.general)
  • Re: Scheduled Task error code:The task completed with an exit code
    ... @echo off ... if exist concatdate.txt del /q concatdate.txt ... You consistently fail to specify a drive and a path for your ... *** You must specify the exact file locations. ...
    (microsoft.public.windows.server.general)
  • Re: Scheduled Task error code:The task completed with an exit code
    ... echo %fileDATE%>filedate.txt ... if exist concatdate.txt del /q concatdate.txt ... You consistently fail to specify a drive and a path for your ... *** You must specify the exact file locations. ...
    (microsoft.public.windows.server.general)
  • Re: cc65 and "Hello World"
    ... There is a section in the Aztec C ReadMe about starting Aztec C SYS ... Many ProDOS system programs created using Aztec C65 will crash ... del time.r ... @echo cinit.ovr now created! ...
    (comp.sys.apple2.programmer)
  • Re: find and remove duplicate files
    ... > What are those strings of characters? ... echo commands. ... wit a "del " ...
    (microsoft.public.win2000.cmdprompt.admin)

Loading