Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In DOS is there a command to perform a similar spool function in SQL or Script command in UNIX to create a log?

I want to print all command line output to a file but I don't want to use the echo command for each line.

I can do the following:

xx.cmd > xx.log

But, it would be nice to just click on the batch/cmd script and generate a log, so that I do not need to get into the command line.

Any help will be appreciated.


share|improve this question

Not that I know of, but you can work around the problem using a prefix like this:

call :start %* > test.log
goto :eof
echo Your code goes here
share|improve this answer
Very nice. It recorded my execution of the bat/cmd script into the log. – dave Jan 2 '13 at 22:43
+1 - You might want to include the parameters in your CALL: call :start %* >test.log – dbenham Jan 3 '13 at 2:57
@dbenham: good point. – Harry Johnston Jan 3 '13 at 3:01

I’m not sure I understand the question –– I especially don’t understand the “I don't want to use the echo command for each line” statement –– but if Harry’s answer is close to what you want, you might like this, too:

@echo off
) >log_file_name

And, of course, if you want to see the commands, leave out the @echo off.

share|improve this answer
I tried this solution, but the log file did not generated. Any idea what went wrong? – dave Jan 2 '13 at 23:11
How did you run it? (I.e., from a Command Prompt, from (Win)+R, from a shortcut/icon, or some other way?) What did you see when you did it? Did the script run at all? Did it terminate normally or abnormally? – Scott Jan 2 '13 at 23:19
I did a command line, (Win)+R, and right click the bat/cmd script to select "Run as administrator". I can see the command is executed in a compmand prompt window very fast, but no log is generated. – dave Jan 2 '13 at 23:24

Your Answer


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.