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-06-29 19:57
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: Batch file for password setting and password verification. View 860 Replies 0
Original Poster Posted 2006-12-25 04:00 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Question: Batch file for password setting and password verification.
Below is a batch file for password setting and password verification that I wrote with reference to some posts.
The problem is that as long as the file _pwda that stores the password is deleted, it becomes useless. Is there any way to solve this?
Also, when entering it here, the password is shown in plain text. Is there any simple way to hide it in the form of ***?
****************************************************************
:pwd
set pwdam=0
If not Exist d:\gghost\temp\_pwda Goto pwd0
for,/f,"tokens=1",%%i,In (d:\gghost\temp\_pwda) Do (
set pwdam=%%i
)

:pwd0
cls
echo.
echo Password Settings
Echo.
echo [1] Software administrator password
echo [2] GRUB boot password (MD5)
echo.
Echo [0] Return to the main screen
Echo [x] Exit
Echo -------------------------------------------------
Echo.
Set pwd=
Set /P pwd= Please choose the operation to perform, then press Enter:

If Not '%pwd%'=='' SET pwd=%pwd:~0,1%
If /I '%pwd%'=='1' Goto pwda
If /I '%pwd%'=='2' GOTO pwd2
If /I '%pwd%'=='0' GOTO BEGIN
If /I '%pwd%'=='x' GOTO exit
Goto pwd


:pwda
cls
Echo.
Echo.
Echo Set administrator password
Echo.
Echo Note: 1. Please be sure to remember the software administrator password. If you forget it, you will not be able to set other passwords;
Echo and this software cannot be uninstalled automatically.
Echo 2. If you just press Enter directly, the administrator password will not be set.
Echo ---------------------------------------------------------
Echo Enter the administrator password you want to set
Echo.
Set /P pwda_1=Please enter:
If %pwda_1%pwda_1==pwda_1 Goto pwd
Echo.
Echo.
Echo Please enter your password again
Echo.
Set /P pwda_2=Please enter again:
If %pwda_2%pwda_2==pwda_2 Goto pwd
If Not %pwda_2%==%pwda_1% Echo.&&Echo The passwords you entered twice do not match, please re-enter&&Echo Please press any key to start setting the password again&&PAUSE >NUL&&Goto pwda
set pwda=%pwda_2%
grub\md5s.exe -d%pwda%>d:\gghost\temp\_pwda
Echo.
Echo.
Echo Password has been set. Please remember your password, press any key to return...
PAUSE>NUL
Goto pwd


:pwd2
if %pwdam%==0 goto pwd2a
Echo.
Echo.
Echo.
Set /P pwd2_0=Please enter the administrator password first:
grub\md5s.exe -d%pwd2_0%>d:\gghost\temp\_ptemp2
for,/f,"tokens=1",%%i,In (d:\gghost\temp\_ptemp2) Do (
set pwd2_0m=%%i
)
del d:\gghost\temp\_ptemp2 >nul
If %pwd2_0m%==%pwdam% Goto pwd2a

cls
Echo.
Echo Sorry! Incorrect administrator password, GRUB boot password cannot be set. Press any key to return...
pause>nul
Goto pwd


:pwd2a
cls
Echo.
Echo Set GRUB boot password (MD5)
Echo.
......
Echo.
Echo.
Echo Password has been set. Please remember your password, press any key to return...
pause>nul
Goto pwd
Windows 一键还原
http://www.yjhy.com
Forum Jump: