Windows command prompt log to a file

后端 未结 3 1177
南旧
南旧 2020-12-08 11:10

I\'d like to easily save the log of the Windows command prompt into a file. Is there any alternative to select everything and right-click on copy?

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 11:30

    You can redirect the output of a cmd prompt to a file using > or >> to append to a file.

    i.e.

    echo Hello World >C:\output.txt
    echo Hello again! >>C:\output.txt
    

    or

    mybatchfile.bat >C:\output.txt
    

    Note that using > will automatically overwrite the file if it already exists.

    You also have the option of redirecting stdin, stdout and stderr.

    See here for a complete list of options.

提交回复
热议问题