Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I schedule a task to execute using the Windows 2008 Task Scheduler, it always executes behind the scenes and I am unable to see the output of it. Generally I execute a bunch of .bat files and I'm used to seeing the cmd window pop up when the scheduler kicks it off. This makes debugging much easier.

I tried redirecting the output to a file, but I found only the output of the .bat file there, not of the program that the .bat file kicked off, which is by far the more interesting output.

I would prefer being able to see the cmd window as it executes, but if I could solve this problem by getting the subject program output to a log file, I would still be delighted.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

you have two options for running this task one is if somebodies logged in and one is run whether somebodys logged in or not. I'd just switch the task to must be logged in for debugging then switch it back to the later for normal use.

share|improve this answer
    
This was very helpful, although you didn't mention the key aspect of doing this, which is that the cmd window shows up if the user is required to be logged in. –  ep4169 Jul 13 '10 at 16:37

It's possible that it redirected the output AND the commands, if you didn't start your batch file with the line

@echo off
share|improve this answer

It sounds like you want to redirect the output of the command called from within the .bat file.

Example.bat

dir \ > Example_output.txt 2>&1

In this case, Example.bat runs a "dir" command on the "\" root directory, and the ">" sends the output of that dir to the file Example_output.txt. The 2>&1 modifies the redirection to include both STDOUT and STDERR, so you'll get everything in your logfile.

Also, the ">" redirection overwrites the output file each time. Use ">>" to append to the existing file, if you want a running log over time.

share|improve this answer
    
This was also a helpful tip; sorry I can't upvote you--not enough rep. –  ep4169 Jul 13 '10 at 16:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.