Link to home
Start Free TrialLog in
Avatar of Mike Broderick
Mike BroderickFlag for United States of America

asked on

Windows 2012 R2 Task Scheduler, call statement doesnt work

I have a Windows 2012 R2 server with a Task Scheduler entry. It executes a bat file nightly. In the bat file is a call statement to another bat file. The statements in the called bat file are not executing. When I run the bat file directly, they work. The task scheduler user is the same as the logged on user. I've tried different users. To debug, I skinnied the files down:

echo on
set ErrFile=C:\TD\CopyUsrErrMsg2.txt
date /t >%ErrFile% 2>&1
time /t >>%ErrFile% 2>&1
call BDSCopy2.bat
echo EndFile >>%ErrFile% 2>&1

BDSCopy2.bat:

@echo subfile   >>%ErrFile% 2>&1

When run directly the output file contains:

Thu 01/16/2014
09:27 AM
subfile  
EndFile


When run from the task scheduler, the output file does not contain the line "subfile". Please note that the production called bat file contains a lot of items; this scenario is just to demo the problem.

Am I missing something? How do I get the called bat file to execute?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

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 Mike Broderick

ASKER

Fantastic! It worked. Thank you!