如何在 Windows/DOS 上捕获 stderr? [英] How to capture stderr on Windows/DOS?
本文介绍了如何在 Windows/DOS 上捕获 stderr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将脚本中的错误捕获到文件中,而不是屏幕上.
I want to capture the errors from a script into a file instead of to the screen.
在 *nix 中,这是通过 stderr 重定向完成的,通常
In *nix, this is done with stderr redirection, usually
echo "Error" 2> errorfile.log
Windows 下如何在 CMD 脚本中实现?
How do I do it in a CMD script under Windows?
推荐答案
例如:
PSKILL NOTEPAD >output.txt 2>&1
这会将 stdout 和 stderr 定向到文件名 output.txt.
This will direct stdout and stderr to a file name output.txt.
请参阅Windows 批处理文件未充分利用的功能,了解更多详情.
See Underused features of Windows batch files for more details.
这篇关于如何在 Windows/DOS 上捕获 stderr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文