&&nul是没有的意思,在批处理中则为后台的空设备,>nul就是指将运行信息输
出到后台空设备也就是运行屏蔽信息,2>nul则是指同样屏蔽错误信息,如:提
示没有找到要执行的命令以及没有找到要执行删除的文件,下面用实例来说明
下:
如:在cmd中运行ping www.cn-dos.net 命令,显示如下:
Pinging www.cn-dos.net with 32 bytes of data:
Reply from 58.215.64.130: bytes=32 time=20ms TTL=50
Reply from 58.215.64.130: bytes=32 time=20ms TTL=50
Reply from 58.215.64.130: bytes=32 time=20ms TTL=50
Reply from 58.215.64.130: bytes=32 time=20ms TTL=50
Ping statistics for 58.215.64.130:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 20ms, Maximum = 20ms, Average = 20ms
现在我们不想运行后显示出以上信息,则可以在后面加上>nul
ping www.cn-dos.net>nul,运行后cmd将停顿3秒左右然后跳出下一行提示
符
如我们运行del /q 5555555555555555.txt>nul(实际上不存在这个文件),一
样会有信息提示:找不到......5555555.txt,但如在后面加上2>nul,运行del /q
5555555555555555.txt>nul 2>nul,则会无任何提示。
总结>nul 2>nul就是屏蔽程序所有信息在屏幕上的输出(包括错误信息)。
[ Last edited by zw19750516 on 2008-5-26 at 12:02 PM ]
批处理之家新域名:www.bathome.net