下面的代码没有像我预期的那样运行。正确的输入部分
if %comp% ==
正在运行,但错误的输入部分 if /I NOT
没有运行。当我输入错误时,它只是关闭,但我希望它从 5 开始倒计时,当倒计时达到 0 时关闭 PC。我已经 Rem
标记了导致部分的问题。
@echo off
mode con: cols=1366 lines=768
TITLE Secur_AI winx64
echo This PC is password protected.
set comp=
set /p comp=Enter Password:
if /I "%comp%"=="Coachify" (
echo Checking Password...
timeout /t 03 /nobreak >NUL
@echo off
color 02
echo Password: Correct
ping 127.0.0.1 -n 1 -w 500 >nul
echo Establishing Firewall....
timeout /t 03 /nobreak >NUL
echo Firewall: Established
ping 127.0.0.1 -n 1 -w 500 >nul
echo Establishing Secure Server Connection.....
timeout /t 03 /nobreak >NUL
echo Secure Connection: Established
ping 127.0.0.1 -n 1 -w 500 >nul
msg * Welcome!
timeout /t 02 /nobreak >NUL
)
if /I NOT "%comp%"=="Coachify" (
echo Checking Password...
timeout /t 03 /nobreak >NUL
@echo off
color 04
TITLE Self_Shutdown_Prompt
echo Wrong Password.
ping 127.0.0.1 -n 1 -w 100 >nul
echo Intruder Detected.
ping 127.0.0.1 -n 1 -w 100 >nul
echo Initiating Protection Mode...
timeout /t 03 /nobreak >NUL
echo Protection Mode Initiated.
timeout /t 01 /nobreak >NUL
set SecondsLeft=6
call :LOOP %SecondsLeft%
goto END
:LOOP
cls
set /a SecondsLeft=%SecondsLeft%-1
Rem Start of problem area.
if %SecondsLeft% == 0 goto :eof
call echo Initiating SelfShutdown in... %SecondsLeft% seconds.
ping -n 2 127.0.0.1 >nul
goto LOOP
:END
Rem End of problem area.
shutdown -s -t 00
)
谁能告诉我我做错了什么?
@Compo 建议的解决方案有效。 这是重新更正的代码:
@echo off
mode con: cols=1366 lines=768
TITLE Secur_AI winx64
echo This PC is password protected.
set comp=
set /p comp=Enter Password:
if /I "%comp%"=="Coachify" (
echo Checking Password...
timeout /t 03 /nobreak >NUL
@echo off
color 02
echo Password: Correct
ping 127.0.0.1 -n 1 -w 500 >nul
echo Establishing Firewall....
timeout /t 03 /nobreak >NUL
echo Firewall: Established
ping 127.0.0.1 -n 1 -w 500 >nul
echo Establishing Secure Server Connection.....
timeout /t 03 /nobreak >NUL
echo Secure Connection: Established
ping 127.0.0.1 -n 1 -w 500 >nul
msg * Welcome!
timeout /t 02 /nobreak >NUL
goto :eof
)
echo Checking Password...
timeout /t 03 /nobreak >NUL
@echo off
color 04
TITLE Self_Shutdown_Prompt
echo Wrong Password.
ping 127.0.0.1 -n 1 -w 100 >nul
echo Intruder Detected.
ping 127.0.0.1 -n 1 -w 100 >nul
echo Initiating Protection Mode...
timeout /t 03 /nobreak >NUL
echo Protection Mode Initiated.
timeout /t 01 /nobreak >NUL
set SecondsLeft=6
call :LOOP %SecondsLeft%
goto END
:LOOP
cls
set /a SecondsLeft=%SecondsLeft%-1
if %SecondsLeft% == 0 goto :eof
call echo Initiating SelfShutdown in... %SecondsLeft% seconds.
ping -n 2 127.0.0.1 >nul
goto LOOP
:END
shutdown -s -t 00