找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 18288|回复: 2

[其他] [已解决]模拟用户注册、登录的批处理一个BUG,有无大佬能够解决,非常感谢,急

[复制链接]
发表于 2023-5-14 18:25:53 | 显示全部楼层 |阅读模式
本帖最后由 BingjianREMIX 于 2023-5-19 23:23 编辑

这是一个bug,他注册的时候注册名为空,密码为空,登录时用户名为空,密码为空也能登录,求解
  1. :login
  2. cd /d %~dp0
  3. title MICRODOS LOGIN ^& REGISTER
  4. setlocal enabledelayedexpansion
  5. if not exist urini.ini call :register
  6. cls

  7. :users2
  8. color 07
  9. cls
  10. echo.
  11. echo -------------------------
  12. echo MICRODOS LOGIN ^& REGISTER
  13. echo -------------------------
  14. echo.
  15. echo 1.Login
  16. echo.
  17. echo 2.register
  18. echo.
  19. set /p a=Enter you choose:
  20. if /i "%a%" equ "2" (
  21.         call :register
  22.         goto :users2
  23. ) else if "%a%" equ "1" (
  24.         set /p str1=Enter the USER NAME:
  25.         set /p str2=Enter the password:
  26.         findstr /x /c:"USER NAME:!str1! PASSWORD:!str2!" "urini.ini" 1>nul && (
  27.                 cls
  28.                 color 27
  29.                 echo TRUE!
  30.                 echo Please push any key to continue!
  31.                 pause>nul
  32.                 goto :dos
  33.         ) || (
  34.                 cls
  35.                 color 47
  36.                 echo ERROR!
  37.                 echo Please push any key to continue!
  38.                 pause>nul
  39.                 goto :users2
  40.         )
  41. ) else goto :users2

  42. :register
  43.         set /p str1=Enter the new user name:
  44.         set /p str2=Enter the new password:
  45.         >>"urini.ini" echo USER NAME:%str1% PASSWORD:%str2%
  46.         goto :users2
复制代码
发表于 2023-5-14 20:37:31 | 显示全部楼层
那就加给判断吧 判断str1 str2是否为空
发表于 2023-5-14 21:49:45 | 显示全部楼层
回复 1# BingjianREMIX
  1. :register
  2. set "str1="
  3. set /p "str1=Enter the new user name:"
  4. if "x%str1%" equ "x" (
  5.     echo Invalid user name.
  6.     goto :register
  7. )
  8. set "str2="
  9. set /p "str2=Enter the new password:"
  10. if "x%str2%" equ "x" (
  11.     echo Invalid password.
  12.     goto :register
  13. )
  14. >>"urini.ini" echo USER NAME:%str1% PASSWORD:%str2%
复制代码

评分

参与人数 1技术 +1 收起 理由
BingjianREMIX + 1 厉害,完美解决

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-18 20:11 , Processed in 0.017192 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表