Redirect Windows cmd stdout and stderr to a single file

前端 未结 7 1767
醉梦人生
醉梦人生 2020-11-22 10:11

I\'m trying to redirect all output (stdout + stderr) of a DOS command to a single file:

C:\\>dir 1> a.txt 2> a.txt
The process cannot access the fil         


        
7条回答
  •  北海茫月
    2020-11-22 10:56

    In a batch file (Windows 7 and above) I found this method most reliable

    Call :logging >"C:\Temp\NAME_Your_Log_File.txt" 2>&1
    :logging
    TITLE "Logging Commands"
    ECHO "Read this output in your log file"
    ECHO ..
    Prompt $_
    COLOR 0F
    

    Obviously, use whatever commands you want and the output will be directed to the text file. Using this method is reliable HOWEVER there is NO output on the screen.

提交回复
热议问题