Windows command to perform a similar function to spool command in SQL or Script command in UNIX?
14,759
Not that I know of, but you can work around the problem using a prefix like this:
call :start %* > test.log
goto :eof
:start
echo Your code goes here
Related videos on Youtube
Author by
dave
Updated on September 18, 2022Comments
-
dave over 1 year
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.
Dave
-
dave over 11 yearsVery nice. It recorded my execution of the bat/cmd script into the log.
-
dave over 11 yearsI tried this solution, but the log file did not generated. Any idea what went wrong?
-
Scott - Слава Україні over 11 yearsHow 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?
-
dave over 11 yearsI 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.
-
dbenham over 11 years+1 - You might want to include the parameters in your CALL:
call :start %* >test.log
-
Harry Johnston over 11 years@dbenham: good point.