I am trying to build a batch file (Using MS Notepad) to accomplish the following:
Write a message to the console ("Running Task X - Do not interrupt")
Run some commands with the output being written to a log file
Pause
CLEAR THE SCREEN (CLS)
Write a different message to the console ("Running Task Y - Do not interrupt")
Run some more commands with the output being written to the log file
Pause until the screen is manually cleared
When I run my test file directly by double-clicking it, the Clear Screen command works as expected. (of course, the output of steps 2 and 6 will also show on the screen rather than being written to a log file)
When I run the file from the task scheduler, The CLS is ignored and BOTH messages will show on the screen (In this case, the output of steps 2 and 6 is properly directed to a log file)
How can I properly clear the screen when running the file from Task Scheduler?
My batch test file:
@Echo OFF
mode con: cols=85 lines=40
echo === This machine is currently performing task "X" Please do NOT interrupt === >con
Dir PlaceHolder*
Pause >con
@CLS
echo === This machine is currently performing task "Y" Please do NOT interrupt === >con
Dir PlaceHolder2*
Pause >con
@Exit
Turns out, if you only use "@CLS" (as I did), the Clearscreen command gets directed to the LOG rather than to the screen. Since the log CANNOT be cleared, the batch file prepends the next line of output with an upwards arrow and calls it a day. You will need to ensure you explicitly route the Clearscreen command to the console/screen (@CLS >con) in which case it will work as expected.