首页 > 解决方案 > 为什么 set 命令会抛出错误?

问题描述

我正在尝试批量制作程序,但 CMD 一直告诉我 SET 命令的语法不正确:

choice /m "Show or hide?" /c SH
set choice=%errorlevel%

这是怎么回事?它应该不会引发任何错误。

整个脚本:

rem @echo off
choice /m "Show or hide?" /c SH
set choice=%errorlevel%
if %choice%==1 (
net user administrator /active:yes
) else if %choice%==2
net user administrator /active:no
) else (
echo "Invalid option"
)
pause

标签: batch-file

解决方案


(在行尾丢失

) 否则如果 %choice%==2(


推荐阅读