标题: [其他] [已解决]模拟用户注册、登录的批处理一个BUG,有无大佬能够解决,非常感谢,急 [打印本页]
作者: BingjianREMIX 时间: 2023-5-14 18:25 标题: [已解决]模拟用户注册、登录的批处理一个BUG,有无大佬能够解决,非常感谢,急
本帖最后由 BingjianREMIX 于 2023-5-19 23:23 编辑
这是一个bug,他注册的时候注册名为空,密码为空,登录时用户名为空,密码为空也能登录,求解- :login
- cd /d %~dp0
- title MICRODOS LOGIN ^& REGISTER
- setlocal enabledelayedexpansion
- if not exist urini.ini call :register
- cls
-
- :users2
- color 07
- cls
- echo.
- echo -------------------------
- echo MICRODOS LOGIN ^& REGISTER
- echo -------------------------
- echo.
- echo 1.Login
- echo.
- echo 2.register
- echo.
- set /p a=Enter you choose:
- if /i "%a%" equ "2" (
- call :register
- goto :users2
- ) else if "%a%" equ "1" (
- set /p str1=Enter the USER NAME:
- set /p str2=Enter the password:
- findstr /x /c:"USER NAME:!str1! PASSWORD:!str2!" "urini.ini" 1>nul && (
- cls
- color 27
- echo TRUE!
- echo Please push any key to continue!
- pause>nul
- goto :dos
- ) || (
- cls
- color 47
- echo ERROR!
- echo Please push any key to continue!
- pause>nul
- goto :users2
- )
- ) else goto :users2
-
- :register
- set /p str1=Enter the new user name:
- set /p str2=Enter the new password:
- >>"urini.ini" echo USER NAME:%str1% PASSWORD:%str2%
- goto :users2
复制代码
作者: terse 时间: 2023-5-14 20:37
那就加给判断吧 判断str1 str2是否为空
作者: Batcher 时间: 2023-5-14 21:49
回复 1# BingjianREMIX - :register
- set "str1="
- set /p "str1=Enter the new user name:"
- if "x%str1%" equ "x" (
- echo Invalid user name.
- goto :register
- )
- set "str2="
- set /p "str2=Enter the new password:"
- if "x%str2%" equ "x" (
- echo Invalid password.
- goto :register
- )
- >>"urini.ini" echo USER NAME:%str1% PASSWORD:%str2%
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |