Link to home
Start Free TrialLog in
Avatar of Ksean
KseanFlag for United States of America

asked on

Task Scheduler with Batch file

Hello,
I have a batch file(*.bat) to run with Task Scheduler but I am getting error as below

Event ID 203
Task Scheduler failed to launch action "c:\windows\system32\cmd.exe" in instance

I have tried a couple of things but it still doesn't work

Thanks in advance
Avatar of netcmh
netcmh
Flag of United States of America image

Does the batch file run successfully when executed manually?

Then, in the section of task scheduler I also check the box "Run with highest privileges", though I don't know whether that would be necessary in your case.
Is this vista?

If the event id is 203, is the Error Value: 2147942667?

If so, then

Error code 2147942667 indicates that the directory name is invalid. In most cases, this is caused by placing quotes around the "Start In" directory.

Resolution?

Remove the surrounding quotes from the "Start In" path.

The path of the program to launch must be surrounded by quotes if it contains spaces; the "Start In" path must not be surrounded by quotes.
Avatar of Ksean

ASKER

manually no problem. and also it is on windows 2008 server.

I do not have anything in Start in. Do I have to put anything?

batch file (file.bat) is in c:\program files\backup\backup.bat

When I put one command in program/script, no problem

but the batch file has many command inside.

Thanks
If you could, could you please upload your batch file for me to see?
Avatar of Ksean

ASKER

Here you are

@echo on
SETLOCAL ENABLEDELAYEDEXPANSION
set JavaCmd1=Java -classpath . ServiceStat bodeans 3306
set JavaCmd2=Java -classpath . ServiceStat scandal 80
set JavaCmd3=Java -classpath . ServiceStat scandal 389
set DOSCmd=DIR C:\Windows

Set Counter=1
set Result=
 
:Loop
for /f "tokens=1" %%a in ('!JavaCmd%Counter%!') do set Result=%Result%%%a

echo %Result%|findstr /i "yesyesyes"
if not errorlevel 1 GOTO DOCOMMAND

echo %Result%|findstr /i "errorerrorerror"
if not errorlevel 1 goto :EOF
 
echo %Result%|findstr /i "nonono"
if not errorlevel 1 goto :EOF
 
echo %Result%|findstr /e /i "no"
if not errorlevel 1 (
    echo %Time% started waiting 5 minutes...
    ping -n 300 loopback
    goto Loop
)
 
echo %Result%|findstr /e /i "yes"
if not errorlevel 1 Set /a Counter+=1
if %Counter% LEQ 120 goto Loop
goto DOCOMMAND
 
:DOCOMMAND
sc start glassfishDomain1
GOTO :EOF

Task Scheduler says it is running  but I never see dos windows that shows it is running

Thanks
ASKER CERTIFIED SOLUTION
Avatar of netcmh
netcmh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ksean

ASKER

netcmh,
Thanks for your help.
I just found solution myself. If I use option called "create basic task" instead of "create task", it just works
There may be some permission or security issues even though I used administrator for this task.
Thanks anyway