win批处理总结

1.注释采用 “::”

2.输出采用echo STRING

echo. 用来输出空行

3.变量赋值 set/a date=1

4.变量使用 %date%

5.打印当前目录 cd

6.判断文件是否存在 if not exist filename

判断变量是否相等 if “%date%”==”1”

7.语句跳转如

:sign

……

goto sign

98变量的赋值问题:

set/a date=1

set/a date=%date%+1 && echo date=%date%

此时打印date=1

set/a date=1

set/a date=%date%+1

echo date=%date%

此时打印date=2

10.输入变量

set date=
set/p date=Please input date:

11.运行可执行文件

call filename

12.if else语句

if %a%==1 (

……

) else (

……

)

else和括号前后都要有空格。

13.命令行参数

%1 %2 ……%9分别表示参数1到9

“%”本身用“%%”表示

14.for循环

for /l %%i in (1,1,8) do (

……

)

循环八次

15.清屏用cls

2 thoughts on “win批处理总结

  1. 对了,XylFTP客户端的win批处理有问题。如果系统不安装在C盘的话,你那个就不行了!请修改!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.