从批处理文件中的嵌入式命令中抑制错误以进行循环


0

我有一个批处理文件,它使用该for命令来解析另一个命令的输出,但我希望抑制写入STDERR的所有错误。

我试过这个:

for /F "usebackq delims=" %%a in (`mycommand.exe 2>nul`) do set RESULT=%%a

其中我试图将STDERR重定向到内部嵌入式命令的nul,但是我得到了这个错误:

2> was unexpected at this time.

如何忽略由此产生的所有错误mycommand.exe

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.