Link to home
Start Free TrialLog in
Avatar of computerconcepts
computerconceptsFlag for United States of America

asked on

Task Scheduler - Windows Server 2008 - Will not run a batch file

We have several tasks scheduled and most of them run fine.  The only one having a problem is one that runs a batch file.  The batch file is supposed to open Microsoft Access and run a macro.  This is the batch file:

PATH = "C:\Program Files (x86)\Microsoft Office\Office11;C:\Windows\Command"
START /WAIT MSACCESS.EXE "c:\JM\jmTransfer\outside reports for staff - New.mdb" /x "RunExport"
C:\JM\jmTransfer\theFtpmdb.exe

I can run the batch file by itself and there are no problems.  It's only when task scheduler tries to run it there's a problem.  The task is running as the domain administrator and configured to run whether the user is logged on or not.  I've also tried checking the box to "run with highest privileges" but it doesn't make a difference.

When I run it the event history shows it stops here:
Task Scheduler launch task "\FTP Files" , instance "C:\Windows\SYSTEM32\cmd.exe"  with process ID 8232.

Thanks for your help!
Craig
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

did you try to run it as SYSTEM account?
whats the error message in the Task schedular
Avatar of computerconcepts

ASKER

Thanks for your replies.  I'm out of the office til Monday.  I'll get answers for you then.
There is no error message, it just runs forever or until I end it.  I've since set up a time limit so it at least ends after a couple hours.

I just tried running it as the SYSTEM account but no luck.  It does the same thing where it will run, report that > Task Scheduler launch task "\FTP Files" , instance "C:\Windows\SYSTEM32\cmd.exe"  with process ID xxxx.  Then it just sits there like it's waiting on something or getting stuck doing something.

More info: When I manually run the batch file it only takes 15-20 seconds to complete.
Avatar of Rich Weissler
Rich Weissler

The option "run whether the user is logged on or not" causes your scheduled task to run in 'Session 0', which prevents any interaction with the 'Session 1' where user processes usually run.  Apparently MSAccess will fail when run in Session 0.  :-(

More information on server side automation in MS Office are available on Microsoft's support site..

The long term solution will be to migrate the needed functionality to a supported server side solution.

Short term: if you leave the intended domain user account logged in (and the screen locked), and instruct the process to only run when the user is logged in, does your process run correct?  Again, I wouldn't suggest it as a long term solution... but for (a) testing and (b) very short term, I'd be curious to hear if that works.
Thanks Razmus,

I just tried running as "run only when user is logged on" but it didn't make a difference.  

I should have mentioned this before but I just thought of it, sorry :( but this task is running on a member server.  This task was running fine before we replaced the domain controller and the local domain changed.  I believe the task was running with local admin credentials before the server change but by the time I was called to troubleshoot it was changed to domain admin credentials.  I've since been messing with different configurations with no luck.  The rest of the tasks are running with local admin credentials.

I'm just wondering why this one died and none of the others were affected?
ASKER CERTIFIED SOLUTION
Avatar of Rich Weissler
Rich Weissler

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
Oh wow.  I checked the local security policy of the member server and it listed "domain\Administrators" in the 'Logon as a batch job' policy but when I added my specific domain admin account and tried the scheduled task it now works!!!!

Thank you so much Razmus.  I would have never thought to check that policy.