中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-11 01:22
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Solved] How to modify this code: batch file password verification program
Printable Version  1,002 / 7
Floor1 provem Posted 2008-12-12 19:14
初级用户 Posts 82 Credits 92


This code was written by someone else. My idea is:
if the BB.txt file does not exist, then display a prompt (if it exists, then run the password verification program according to bb.txt)
For first-time use, please set a password:
Then save it to BB.txt
When running the program again next time

───────────────── Moderator record ─────────────────
Executed by: HAT
Action: added search keywords to the thread title
Explanation: the original title "Everyone help me see how to modify this code" was not helpful for forum searching
Penalty: deducted 2 credits
Reminder: it is recommended to read the following threads
{1415}The Wisdom of Asking Questions
{7326}Forum newbie must-read, the basic code of conduct for everyone
{22703}Please don't be an impetuous person
{32667} Those people who can't even write a clear title, wake up
{32825}Strict cleanup of lousy posts in this section
───────────────── Moderator record ─────────────────


[ Last edited by HAT on 2008-12-13 at 22:56 ]
Floor2 tireless Posted 2008-12-12 21:16
银牌会员 Posts 1,122 Credits 2,025
@echo off
if exist bb.txt goto next
set /p password=For first-time use, please set a password:
echo.%password%>bb.txt

:next

for /f "delims=" %%i in (bb.txt) do set passwords=%%i
:begin
cls&set /p password= Please enter the password:
...


Does the part from :set to :wrong have any chance to execute?
Floor3 provem Posted 2008-12-13 01:31
初级用户 Posts 82 Credits 92
Can someone write code based on the above idea that can set a password and change a password?
Floor4 radem Posted 2008-12-13 01:46
高级用户 Posts 383 Credits 691
Change:
if "%password%"=="%passwords%" goto ok
to:
if "%password%"=="%passwords%" goto set
Floor5 provem Posted 2008-12-13 02:32
初级用户 Posts 82 Credits 92


Everyone help me take a look, with the code above, after setting the password the content written to bb.txt is: ECHO is off.
Where exactly is the problem?
Floor6 provem Posted 2008-12-13 02:35
初级用户 Posts 82 Credits 92


This is the code for changing the password. Everyone take a look, is this okay?
Floor7 ZJHJ Posted 2008-12-13 14:31
高级用户 Posts 374 Credits 609


[ Last edited by ZJHJ on 2008-12-13 at 21:31 ]
Floor8 provem Posted 2008-12-13 21:53
初级用户 Posts 82 Credits 92
Thanks, ZJHJ.
What I wanted was: if the M.rqm file does not exist, then prompt the user to set a password; if it exists, then use the contents of M.Rqm to verify the password. I've already solved the problem, thanks.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023