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.



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
  • 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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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