1,交互式案例:
@echo off cls title Repairing function :menu cls color 0A echo. echo ================================================== echo Select the action you want to take and press Enter echo ================================================== echo. echo 1.网络修复及上网相关设置,修复IE,自定义屏蔽网站 echo. echo 2.病毒专杀工具,端口关闭工具,关闭自动播放 echo. echo 3.清除所有多余的自启动项目,修复系统错误 echo. echo 4.清理系统垃圾,提高启动速度 echo. echo Q.exit echo. echo. :cho set choice= set /p choice= please choice: if not "%choice%"=="" set choice=%choice:~0,1% if /i "%choice%"=="1" goto ip if /i "%choice%"=="2" goto setsave if /i "%choice%"=="3" goto kaiji if /i "%choice%"=="4" goto clean if /i "%choice%"=="Q" goto endd echo The selection is invalid. Please re-enter echo. goto cho
2,if语句综合运用
@echo off set sum=0 call :sub sum 10 20 35 echo result:%sum% pause :sub rem 参数1为返回变量名称 set /a %1=%1+%2 shift /2 if not "%2"=="" goto sub goto :eof :: 求和 ::shift /n 从第n个参数开始移位