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-24 01:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Modify the batch file's own password View 1,742 Replies 11
Original Poster Posted 2008-04-13 11:59 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 61
Posts 24
Joined 2007-08-24 21:03
18-year member
UID 95773
Gender Male
Status Offline
The following is a piece of code. Enter the correct password 123456 to enter the password modification. Please write the one who is good at modifying their own password: 123456

@echo off
chcp 437>nul&graftabl 936>nul
echo hP1X500Pf3/f1/5++u5x>in.com
set /p password=Please enter password:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
if /i "%password%"=="123456" goto 密码修改
echo Wrong password: "%password%"
echo The program will automatically exit after 3 seconds.
ping -n 3 127.0.0.1>nul
exit

:密码修改
cls
echo Please complete the modification of the 123456 password
pause
Floor 2 Posted 2008-04-13 12:26 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 61
Posts 24
Joined 2007-08-24 21:03
18-year member
UID 95773
Gender Male
Status Offline
No, I can't get to the password modification page.
Floor 3 Posted 2008-04-13 12:48 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 61
Posts 24
Joined 2007-08-24 21:03
18-year member
UID 95773
Gender Male
Status Offline
Just found relevant information, and the problem has been solved!
Floor 4 Posted 2008-04-13 13:13 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
When testing, I removed the password hiding. Please the owner add it by himself.
@echo off 
set /p password=Please enter the password:
for /f "tokens=2" %%i in (%~nx0) do set oldpassword=%%i
if "%password%"=="%oldpassword%" goto Modify password
cls
echo Wrong password:%password%
echo The program will automatically exit after 3 seconds.
ping -n 3 127.0.0.1>nul&goto :eof
:Modify password
cls
set /p pwd=Please modify the password:
cls
set /p pwds=Please confirm your password again:
cls
if not "%pwd%"=="%pwds%" echo Please return to enter correctly&ping /n 2 127.1>nul&goto Modify password
cls
echo Password modified successfully, the new password is %pwd%
echo :: %pwd%>>%~nx0
pause&goto :eof
:: 123456

ps Please the owner post your method to learn together.

[ Last edited by zw19750516 on 2008-4-17 at 08:11 PM ]
批处理之家新域名:www.bathome.net
Floor 5 Posted 2008-04-13 14:40 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 61
Posts 24
Joined 2007-08-24 21:03
18-year member
UID 95773
Gender Male
Status Offline
This is found from the forum, it feels very good!
@echo off
if exist M.RQM goto bn
rem llts in 0070303schj by q@251485609
@echo 12345678>M.RQM
:bn
@cls
@echo off
@echo.
@echo.
@echo.
@echo For the safety of user settings, this program requires an administrator to enter and operate!
@echo.
@echo.
@echo Enter T to exit
@echo.
@echo ------- * -------- * --------
@echo.
@echo Initial password: 12345678
@echo.
SET /P SY= Please enter the administrator password:
FOR /F %%I IN (M.RQM) DO SET syq=%%I
IF "%SY%" == "%syq%" GOTO kyjr
IF "%SY%" == "CK" GOTO ckmm
IF "%SY%" == "T" GOTO :eof
@cls
@echo.
@echo.
@echo.
@echo Sorry, (the password may have been changed) you are not an administrator and cannot enter and operate!
pause>nul
@goto bn
:kyjr
@cls
@echo.
SET /P SYg= Please press any key to enter the program (if you need to change the original password, please enter XGMM):
IF "%SYg%" == "XGMM" GOTO xg
IF not "%SYg%" == "XGMM" goto k
:xg
@cls
SET /P xmm= Please enter the new password:
@echo %xmm%>xmm.txt
SET /P cxmm= Please enter it again:
FOR /F %%I IN (xmm.txt) DO SET xsyq=%%I
IF "%cxmm%" == "%xsyq%" GOTO gng
@echo Password does not match!
pause
goto xg
:gng
COPY xmm.txt M.RQM
@echo Password changed successfully! Please remember this password.
pause>nul
goto bn
:ckmm
@cls
FOR /F %%I IN (M.RQM) DO SET syq=%%I
@echo %syq%
pause>nul
goto bn
:k
del xmm.txt
@cls
@echo Enter the use program
pause>nul
Floor 6 Posted 2008-04-13 15:47 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Originally posted by fourme2009 at 2008-4-13 14:40:
This is found from the forum, and it feels very good!
@echo off
if exist M.RQM goto bn
rem llts in 0070303schj by q@251485609
@echo 12345678>M.RQM
:bn
@cls
@echo off
@echo.
@echo.
@echo.
@echo ...

Two files are generated, one of which is a temporary xmm.txt file, and the other is an m.rqm file. Strictly speaking, it doesn't count as self-modification. And my method doesn't generate any temporary files. Please compare it yourself, the landlord.

[ Last edited by zw19750516 on 2008-4-13 at 03:51 PM ]
批处理之家新域名:www.bathome.net
Floor 7 Posted 2008-04-27 12:44 ·  中国 安徽 亳州 电信
新手上路
Credits 2
Posts 1
Joined 2008-04-27 12:22
18-year member
UID 117087
Gender Male
Status Offline
Floor 8 Posted 2008-04-28 01:14 ·  中国 广东 广州 电信
中级用户
★★
Credits 233
Posts 117
Joined 2007-11-28 02:38
18-year member
UID 104005
Gender Male
Status Offline
Originally posted by zw19750516 at 2008-4-13 01:13 PM:
I removed the password hiding during testing, please add it yourself, the landlord.
@echo off 
if not "%pwd%"=="%pwds%" echo Please return to correct input&ping /n 2 127.1>nul&goto Modify password
cls
echo Password modified successfully, new password is %pwd%
echo :: %pwd%>>%~nx0
pause&goto :eof
:: 123456


It is better to add an empty line before echo :: %pwd%>>%~nx0,
to avoid the new password and the old password being on the same line,
then, changing the password makes you not know what the password is yourself

For example:

echo Password modified successfully, new password is %pwd%
echo.>>%~nx0
echo :: %pwd%>>%~nx0
pause&goto :eof
:: 123456
Floor 9 Posted 2009-08-03 08:57 ·  中国 广东 珠海 电信
新手上路
Credits 6
Posts 5
Joined 2008-05-01 10:16
18-year member
UID 117451
Gender Male
Status Offline
First, echo set mima=新密码>%0.txt
Then type %0>>%0.txt
ren %0.txt %0
Floor 10 Posted 2009-08-08 00:07 ·  中国 四川 泸州 联通
高级用户
★★★
Credits 609
Posts 374
Joined 2006-08-02 22:38
19-year member
UID 59720
Status Offline
Modifying the batch file's own password is not the best strategy. Because if there is an error, your batch will be broken.
Floor 11 Posted 2009-10-02 16:33 ·  中国 陕西 西安 联通
初级用户
★★
Credits 85
Posts 73
Joined 2007-09-23 23:00
18-year member
UID 98146
Gender Male
Status Offline
Originally posted by ZJHJ at 2009-8-8 12:07 AM:
Modifying the password of the batch file itself is not the best strategy. Because once there is an error, your batch will crash.

I agree with the gentleman. o(∩_∩)o...
Floor 12 Posted 2009-10-04 17:28 ·  中国 四川 绵阳 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Come on, what I want is that P runs once and then deletes itself. Thanks to everyone above.
Forum Jump: