scheduled batch only runs when logged in

Firstly, No I have not got the tick next to "run only when logged on".

I have scheduled a batch file to run using Windows Task Scheduler (WIN 2003 SERVER).

If you manually launch the task it runs fine (result is two emails sent to admin after processing).

If you schedule the task and leave the remote desktop session open, it again runs fine.

But, if you schedule the task and log off, it does not run correctly. (it does launch but it does not perform the process required before emailing admin).

Inside the batch, it calls an application, feeds some locally stored data through it and then saves some reports locally, finally emailing the admin.

The task runs as a network account that has local administrator rights.

Seems to be something to do with security rights while their is no session open... something like "run as batch file" right or something along the lines of that I would have thought.
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.

Look in the properties of the scheduled task (control pannel, scheduled tasks). Is the option "run only if logged on" active?

If this is not enabled, try putting on the run boc cmd in front of the batch file (or cmd /c to terminate command after run). So start the batchfile with: cmd /c batfile.bat
Hi viperacom,
Click Start->Run->%systemroot%\SchedLgU.Txt

Look for the date entry(ies) of the last scheduled run...see if that gives you any indication why it failed.

Also - what type of email script are you using?  Could this script be adjusted to run as SYSTEM?  I've had better success with the local system account...

I too have had your problem when setting scheduled tasks via the GUI.  Have you tried setting from the command line specifying /RU for runas to avoid it using the logged in account?  I have never had this problem when scheduling the jobs remotely.

Below is an example command for scheduling a job from a remote server.

schtasks /create /S /RU runasacctname /RP runasacctpwd /tn taskname /tr c:\task.bat /sc dayparameter /ST timeparameter

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

strange how the 'run as' in the GUI does not work properly
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 Server 2003

From novice to tech pro — start learning today.