
0)@不显示该行
1)随时删除qq下所有gif文件(a.bat),只要能达到目的死循环也可以:
@echo off
if exist C:\Progra~\Tencent\AD\*.gif del C:\Progra~\Tencent\AD\*.gif
a.bat
2)常用的管道命令 | 和 > 和 >>
@echo off
netstat -a -n > tmp.txt
rem 查找所有tcp链接的程序; /I 忽略大小写
type tmp.txt | find "tcp" /I
pause
3)组合命令 & 和 && 和 ||
& 用来连接n个DOS命令,不管命令是否执行失败
&& 用来连接n个DOS命令,一旦命令执行失败,(&&连接的)后面命令将不会执行
|| 用来连接n个DOS命令,即使命令失败也会跑完整个&&连接的命令
@echo off
dir noFolder && ipconfig
echo hello
pause
将&&改成||,再体会下
4)括号的作用(注意是'()' 不是大括号)
if == (dir noFolder
ipconfig)
5)存在判断,也可以用*.*,只不过用跟没有一个样
if exist c:\windows\temp\*.* del c:\windows\temp\*.*
与
if exist c:\windows\temp del c:\windows\temp\*.*
其实是一样的
6)常用DOS命令
如copy、dir、del、type、path、break、start等内部命令,以及ping、net、cmd、at、sort、attrib、fc、find等外部命令
7)
#if 0 命令实现?
for循环实现?(参见http://www.cnblogs.com/focusHr/archive/2009/02/05/1384751.html)
8)没有while循环(用goto代替)
9)没有for实现循环加法
@echo off
set num=
set count= :next
rem /a 表示后面是一个数字表达式
set /a count=%count%+%num%
set /a num=%num%- rem EQU 等于; NEQ 不等于; LSS 小于; LEQ 小于或等于; GTR 大于;GEQ 大于或等于
if %num% NEQ goto next :end
echo count=%count%