Echo does not work with task scheduler

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
3 answers Last reply
More about echo work task scheduler
  1. 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.
  2. 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).
  3. Thanks sminlal,
    That is great advice. I will try that.
Ask a new question

Read More

Windows 7 Command Prompt