禁止Windows命令行中的错误消息

禁止Windows命令行中的错误消息

本文介绍了禁止Windows命令行中的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经在下一个路径文件"C:\users\charqus\desktop\MyFolder"上创建了一个文件夹,并且我在CMD上运行了下一个命令:

Let's say I already have a folder created on the next path file: "C:\users\charqus\desktop\MyFolder", and I run the next command on CMD:

mkdir "C:\users\charqus\desktop\MyFolder"

我收到这样的消息:子目录或文件C:\ users \ charqus \ desktop \ MyFolder已经存在" .

I get a message like this: "A subdirectory or file C:\users\charqus\desktop\MyFolder already exists".

因此,命令行中是否有任何命令可以消除此返回的消息?我试过回声,但这不是我想要的.

Therefore, is there any command in the commandline to get rid of this returned messages?I tried echo off but this is not what I looking for.

推荐答案

将输出重定向到nul

mkdir "C:\users\charqus\desktop\MyFolder" > nul

根据命令,您可能还需要重定向错误:

Depending on the command, you may also need to redirect errors too:

mkdir "C:\users\charqus\desktop\MyFolder" > nul 2> nul

Microsoft在此处介绍了这些选项,这对阅读很有帮助.

Microsoft describes the options here, which is useful reading.

这篇关于禁止Windows命令行中的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:00