中国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-01 19:02
48,037 topics / 350,122 posts / today 2 new / 48,249 members
DOS批处理 & 脚本技术(批处理室) » How to set a password input in batch processing
Printable Version  1,475 / 5
Floor1 dengt Posted 2006-05-28 10:43
新手上路 Posts 2 Credits 8
How to set a password input in batch processing?
I want to load a line in the autoexec.bat of the system to prompt for a password. If the password I enter is correct, it will continue to execute. If it is incorrect, it will continue to prompt for the password 3 times. (It can also jump to other batch processing to execute if the password input is incorrect.)
I heard that it can be written with SET?
Hope the expert can answer
Floor2 Climbing Posted 2006-05-28 11:27
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
You did not specify the running environment of the batch processing. If it is the cmd environment, you can input using set /p:

@echo off
set num=0
:loop
set /p pass=Please input password:
if "%pass%"=="MyPass" goto next
set /a num=%num% + 1
if %num%==3 goto error
goto loop

:error
other.cmd

:next
...

Tested on xp.
Floor3 dengt Posted 2006-05-28 13:24
新手上路 Posts 2 Credits 8
I want something that can run under pure DOS
Floor4 Climbing Posted 2006-05-28 20:03
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
In pure DOS, the only things I know are using third-party tools, such as WBAT or XSET, GET and such tools.
Floor5 willsort Posted 2006-05-28 22:20
元老会员 Posts 1,512 Credits 4,432
Regarding dengt:

There are also codes that don't use third - party tools, but they are relatively complicated. If you are interested, you can refer to ; if it is allowed to display the password in plain text, then the problem degenerates into obtaining the password string from the input end and then comparing it, and the code can be simpler.

Password program (batch) with custom password
http://www.cn-dos.net/forum/viewthread.php?tid=8804
Floor6 jimolr Posted 2006-06-10 15:39
初级用户 Posts 18 Credits 48
Thanks for helping me solve the same problem
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023