China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 17:57
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to set a password input in batch processing View 1,474 Replies 5
Original Poster Posted 2006-05-28 10:43 ·  中国 福建 三明 电信
新手上路
Credits 8
Posts 2
Joined 2006-05-24 11:19
20-year member
UID 55909
Status Offline
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
Floor 2 Posted 2006-05-28 11:27 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
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.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2006-05-28 13:24 ·  中国 福建 三明 电信
新手上路
Credits 8
Posts 2
Joined 2006-05-24 11:19
20-year member
UID 55909
Status Offline
I want something that can run under pure DOS
Floor 4 Posted 2006-05-28 20:03 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
In pure DOS, the only things I know are using third-party tools, such as WBAT or XSET, GET and such tools.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 5 Posted 2006-05-28 22:20 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2006-06-10 15:39 ·  中国 云南 昆明 电信
初级用户
Credits 48
Posts 18
Joined 2006-06-10 14:24
20-year member
UID 56835
Status Offline
Thanks for helping me solve the same problem
Forum Jump: