在CMD中写入密码时出现问题
如果有人键入带有一个或多个空格的密码,它将退出并返回: 意外的(…) 例如: 我输入密码:测试1 它返回:意外的1 我的朋友,这一批刚刚结束! 有没有办法让它忽略空格 以下是完整的代码:在CMD中写入密码时出现问题,cmd,passwords,Cmd,Passwords,如果有人键入带有一个或多个空格的密码,它将退出并返回: 意外的(…) 例如: 我输入密码:测试1 它返回:意外的1 我的朋友,这一批刚刚结束! 有没有办法让它忽略空格 以下是完整的代码: @echo off if time GTR 14.00 goto ALLOW title Security echo Your computer started at %date%! Time: %time%! >> Reports.txt echo taskkill /f /IM explo
@echo off
if time GTR 14.00 goto ALLOW
title Security
echo Your computer started at %date%! Time: %time%! >> Reports.txt
echo taskkill /f /IM explorer.exe
shutdown /s /t 60
msg * Please enter the password in the box!
:START
cls
set /p PSW = Enter the password here:
if %PSW% == test (
goto END
) else (
if not %PSW% == test goto TRYAGAIN
)
goto start
:END
shutdown /a
msg * Correct!
start explorer.exe
taskkill /f /IM cmd.exe
:TRYAGAIN
msg * Wrong! Try again!
goto START
:ALLOW
taskkill /f /IM cmd.exe
引号保护空格和
字符等
if "%PSW%" == "test" (
goto END
) else (
goto TRYAGAIN
)