我找不到我的代码关闭程序帮助需要的原因!当我运行该程序时,我可以进入该程序然后随机关闭我一直在尝试修复它一小时,请帮助
@echo off
title Services Program
color 0e
set mainMenu=0
goto check_Permissions
:check_Permissions
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate.
echo Restart this program but run it in administrator mode!
pause >nul
)
pause >nul
goto main
:main
cls
echo Main Menu
echo.
echo 1 - Start
echo 2 - Options
echo 3 - Exit
set /p id=Enter The Value:%=%
IF %id%==1(
echo Pow
pause
)
goto main
:program
echo Insert Program here
pause
goto main
:options
echo Options
pause
goto main
答案 0 :(得分:1)
IF %id%==1(
语法不正确。
IF "%id%"=="1" (
应该有效。 (
之前的空格必需
由于id
可能有或没有值,或者可能包含空格或其他分隔符或批次发现令人反感的笨拙字符,请将其括在"quotes"
中以消除对(空,包含分隔符)的敏感度)[但不幸的是"unbalanced quotes
]
==
运算符的两边需要exactly
匹配 - 所以引号必须包含在两边。
答案 1 :(得分:0)
你的错误
IF %id%==1(
首先,它在括号前需要一个空格,然后你进行了错误的比较,因为" =="运算符仅在比较字符串时才有效,并且您尝试与数字进行比较。你能做的是:
if %id% EQU 1 ( <--- IF only parses numbers when one of the compare-op operators (EQU, NEQ, LSS, LEQ, GTR, GEQ) is used.
if "%id%" == "1" ( <--- To force a string comparison. The == comparison operator always results in a string comparison.
如需进一步阅读,follow this link