We help IT Professionals succeed at work.

Task Scheduler with Batch file

Ksean
Ksean asked
on
7,902 Views
Last Modified: 2012-06-21
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
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Does the batch file run successfully when executed manually?

CERTIFIED EXPERT

Commented:
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.
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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
CERTIFIED EXPERT

Commented:
If you could, could you please upload your batch file for me to see?

Author

Commented:
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
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.