Sign in with
Sign up | Sign in
Your question

Echo does not work with task scheduler

Tags:
  • Windows 7
  • Command Prompt
Last response: in Windows 7
Share
December 20, 2010 5:03:52 PM

Hi,
Can someone help me? I have Windows 7 X64 home premium. I have a simple batch file that runs perfectly when I run it by double clicking it. When I schedule it to run using task scheduler, it runs except the echo does not create a log file. If run outside the task scheduler, the echo cmd creates log file just fine. Task scheduler history says it ran ok and results look ok, that is, the xcopy command appears to work, but no echo. Here is batch file:

echo. >> testlog.log
echo Start %date% %time% >> testlog.log
xcopy /c /d r:source\*.* r:\dest >> testlog.log
echo End %date% %time% >> testlog.log
echo. >> testlog.log

I have set to run even if user not logged on and at highest priv. The log file is in same folder as bat file. When run from command prompt everything is perfect. Echo does not work when run from task scheduler.

I searched forum but did not see similar problem.
Any ideas???
Thanks for any help

More about : echo work task scheduler

December 20, 2010 8:11:49 PM

OK , I see my problem. I need to supply the path to the log file. It isn't necessary when I execute from command prompt.

Echo now creates log entries.
m
0
l
a c 209 $ Windows 7
December 20, 2010 9:44:59 PM

In the "Actions" properties for a task there's a "Start in (optional)" field - this sets the default path for the process. If you set that to the path you want the log files in, you won't need to specify the path in the script itself.

The advantage of doing it that way is that you can change the location of your files without having to change the code in the script itself (changing a script always runs the risk of screwing it up).
m
0
l
December 21, 2010 12:07:06 AM

Thanks sminlal,
That is great advice. I will try that.
m
0
l
!