set的主要作用是赋值
set /p opt=Enter your option:
先显示Enter your option:,再接收用户输入的内容,以回车表示结束,赋值给变量opt
实例测试:
@echo offecho 1.show ip address
echo 2.show directory:main
set /p opt=Enter your option:if %opt% == 1 goto one
if %opt% == 2 goto twoecho Invalid option
goto main:one
ipconfig /all
pause > nul
exit:two
dir
pause > nul
exit