batch-file - 为什么 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
解决方案
(
在行尾丢失
) 否则如果 %choice%==2(
推荐阅读
- scala - readCsvFile 错误:如何为类型的证据参数指定隐式值
- python - 过滤模型 Django
- sqlite - 循环总是终止或永远继续而没有中断的可能性
- javascript - 通过公共属性对对象进行分组,将其余属性合并为数组中的单独对象
- java - 如何在 Spring Boot 中从 InputStream 创建 MultipartFile 对象
- android - Androids 无法将文件资源与数据绑定链接起来
- linux - 如何在 ubuntu 上安装 awesomewm-git
- python - Python:检查字符串是否以正确的顺序出现在字符列表中
- javascript - react-full-page 模块未找到整页滚动
- reactjs - 在 axios 拦截器中反应本机加载指示器未显示