[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

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

本帖最后由 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
复制代码
QQ 1980286392

那就加给判断吧 判断str1 str2是否为空

TOP

回复 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

评分人数

我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表