2016-07-27 113 views
2

我试图删除y:驱动器,该驱动器使用这一批处理脚本映射到网络目录。如何在批处理脚本中隐藏'net use'命令错误消息

net use y: /d /y>nul 

但在y:不存在的情况下已经删除。它给了我这个错误信息。

The network connection could not be found. 
More help is available by typing NET HELPMSG 2250. 

有没有办法避免打印这个错误?我曾尝试net use y: /d /y>nul>nul,但没有运气

+3

DelboyJay回答这里:[重定向标准输出和stderr到单个文件](http://stackoverflow.com/questions/1420965/redirect-stdout-and-stderr-to-a-single-file) –

回答

2

你应该把它写这样的重定向错误NUL:

@echo off 
net use y: /d /y>nul 2>&1 
pause 

看看:I/O Redirection

3

您不能引起错误在第一位:

if exist y:\ net use y: /delete