Task Scheduler not executing a job (starts and instantly stops)

I am attempting to use Task Scheduler on a Server 2003 to do backups to a drive on the network.  The job runs fine if I right click and then click on "run" BUT it does not execute at all from within the Task Scheduler.

The log:
"BackupDBsToKDsMachine.job" (BackupDBsToKDsMachine.bat)
      Started 3/28/2007 2:00:00 AM
"BackupDBsToKDsMachine.job" (BackupDBsToKDsMachine.bat)
      Finished 3/28/2007 2:00:00 AM
      Result: The task completed with an exit code of (0).

The batch job:
cd E:\

robocopy E:\robocopybackup09\ E:\robocopybackup10 /E /w:1 /r:3 /V /XO

rmdir E:\robocopybackup09 /S /Q

rename E:\robocopybackup08 robocopybackup09
rename E:\robocopybackup07 robocopybackup08
rename E:\robocopybackup06 robocopybackup07
rename E:\robocopybackup05 robocopybackup06
rename E:\robocopybackup04 robocopybackup05
rename E:\robocopybackup03 robocopybackup04
rename E:\robocopybackup02 robocopybackup03
rename E:\robocopybackup01 robocopybackup02

md E:\robocopybackup01

cd C:\

robocopy c:\LIVEAccessDBs\ "E:\robocopybackup01" /E /w:1 /r:3 /XD Windows /XD ClientApps /XF Pagefile.sys /XF NTUSER.DAT /V /XO /Purge


The idea is to have a slowly rotating set of backups and renaming is a much quicker option than doing multiple copies that would otherwise be required.  Again, it works with "run" but not via the task scheduler.

I am setting this up via RDT but that shouldn't make any difference right?  Use a member of the admin group as the user name and the correct password for that user.

Several other jobs run during the night with no problem.  None run at the same time.
michaelmccombAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
I think it may be in the way the schedule is setup - try changing the 'run' line in the task to read
cmd /c x:\pathtobatchfile\batchfile.bat
0
michaelmccombAuthor Commented:
i do not understand that suggestion... i am setting this up by going into "task scheduler", browsing to the batch file and then setting up the weekly times that I wish this job to run...  2AM;Tue,Wed,Thr & Fri (a different and weekly runs on Sat), i tell it it wake the computer and ignor all battery considerations... no expiration date on schedule duration

I guess that I do not understand the 'run' line or where to insert the "cmd /c"  is your suggestion related to the dos prompt?
0
sirbountyCommented:
Yes, I've found some batch files that didn't work properly, unless I prefaced them with a call to the command interpreter.
So, open up your task details (Start->Run->%systemroot%\tasks)
Double-click the task, and instead of
"c:\path to file\myfile.bat"
in the run line, use:
cmd /c "c:\path to file\myfile.bat"
(start in can be left blank, or point to %systemroo%\system32)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

michaelmccombAuthor Commented:
a half dozen other jobs run (not at the same time) without problem...  one of them repeats every ten minutes from 7AM to 7PM and has no trouble at all...  could some sort of networking delay be responsible for the trouble and is there some way to get the job to pause if that IS the case
0
michaelmccombAuthor Commented:
thank you, i will try that...  it does seem to be working now...  i rescheduled the task for 1 minute from now after making the change you suggested and it ran...  i'll leave this open until tomorrow to be certain that it runs this evening but as i say it appears that you have fixed my problem....  would sticking in the "cmd /c" be a good thing to do in general (no particular drawbacks/cures problems)?  Thank you very much!
0
sirbountyCommented:
no drawbacks, no.
I havent put my finger on the why yet...but glad its working for you...
0
Steve KnightIT ConsultancyCommented:
BTW if that doesn't work is E: a local drive or drive mapped as the logged in user?  If it is a network drive you might need to add a net use to the top of the script or use the UNC instead.

Steve
0
michaelmccombAuthor Commented:
DRAT!!!  It did not go.  Same symptom....  starts but then stops instantly.  "net use"???  the network drive it is going to is persistently mapped on the server where the batch job is running.  Having to use "cmd c" would seem redundant so perhaps "net use" would fall into the same category.  None of this seems to make much sense.
0
michaelmccombAuthor Commented:
I just set the job ahead one minute and then sat there and watched it run exactly as it did yesterday when I ran the test.  So I am asking myself what is wrong with 2:00AM without much of an answer BUT I have now changed the job schedule to run the batch at 3:15AM to see if that fixes the problem.  Something is seemingly very strange here.  Rebooted the server about three days ago just in case something was hosed at a deeper level.
0
sirbountyCommented:
Q: Are you logging off, or is the console being locked?
0
michaelmccombAuthor Commented:
i AM logging off and but "locked", not beyond normal passworded login protection...  other jobs do run
0
sirbountyCommented:
You're using an admin account, correct?  With network access?
Try using the /IT parameter in your scheduled task (from the command line) - the equivalent, I believe of "Interactive" checkbox in the gui version...
0
Steve KnightIT ConsultancyCommented:
The drive being persistently mapped as E: makes no difference as it is not mapped for the scheduled task.  Add net use e: \\server\share /persistent:no to the top of your script and try again.  You can add credentials to the line if needed, e.g. net use c: \\server\share /user:username password

As an example if you schedule a task to run cmd.exe you should find it knows nothing of the E: drive - if it is the same user account it may, (but I'm not sure), but only if the same user is already logged in at the console.

Steve
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michaelmccombAuthor Commented:
Alright  i have now mapped the drive with the "net use e:\\ser..." phrase.  Yesterday the job would run if I was logged in and perhaps that is because the logged in admin user was also the user running the batch job.  Early tomorrow morning the job will run once again with the admin user not interactively logged in.  I did a little test running a batch job via the scheduler one minute later and having the interactive user off... the start and stop times for the batch job were not identical indicating that the job ran successfully.  Back on tomorrow to report on the results for the backup job.
0
michaelmccombAuthor Commented:
The same error is occuring... zero execution time indicated and nothing is accomplished

***Scheduled Tasks / Advanced / View Log:OutPut***
"BackupDBsToKDsMachine.job" (cmd)
      Started 3/30/2007 2:00:00 AM
"BackupDBsToKDsMachine.job" (cmd)
      Finished 3/30/2007 2:00:00 AM
      Result: The task completed with an exit code of (0).


***BackupDBsToKDsMachine.job / Properties / Run line***
cmd /c "C:\BatchJobs\BackupDBsToKDsMachine.bat"


***Text of batch file***
net use e: \\\\Kevinsws\RoboBackups /persistent:no

cd E:\

robocopy E:\robocopybackup09\ E:\robocopybackup10 /E /w:1 /r:3 /V /XO

rmdir E:\robocopybackup09 /S /Q

rename E:\robocopybackup08 robocopybackup09
rename E:\robocopybackup07 robocopybackup08
rename E:\robocopybackup06 robocopybackup07
rename E:\robocopybackup05 robocopybackup06
rename E:\robocopybackup04 robocopybackup05
rename E:\robocopybackup03 robocopybackup04
rename E:\robocopybackup02 robocopybackup03
rename E:\robocopybackup01 robocopybackup02

md E:\robocopybackup01

cd C:\

robocopy c:\LIVEAccessDBs\ "E:\robocopybackup01" /E /w:1 /r:3 /XD Windows /XD ClientApps /XF Pagefile.sys /XF NTUSER.DAT /V /XO /Purge


Still running perfectly by hand...  right click on task /  run

??????

0
michaelmccombAuthor Commented:
ok, so i am asking myself what is up with the \\\\ in the "net use" sequence of the run statement.  I do not know how but I MUST be the one who put it in there.... I have now backed it off to only
"net use e: \\Kevinsws\RoboBackups /persistent:no"

it will be over the weekend before I will know if this works
0
sirbountyCommented:
*I have made worse boo-boos than that...don't sweat it.
Good luck and have a nice weekend. :^)
0
michaelmccombAuthor Commented:
Ok, i've flipped it on and off a couple of times and it seems to be that the "net use" suggestion is the one that straightened things out..  I shall remember this and the "cmd c" line in all future batch jobs
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.