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-28 08:27
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Help a newbie take a look at how this batch file should be written! View 602 Replies 1
Original Poster Posted 2004-09-18 00:00 ·  中国 新疆 乌鲁木齐 电信
初级用户
Credits 112
Posts 2
Joined 2004-09-16 00:00
21-year member
UID 31481
Gender Male
Status Offline
A friend asked me a few days ago to help him write a batch file so that after his computer boots twice, it would ask whoever boots it for a password. So I wrote the following, but the result is that no matter how many times it boots, it always asks for the password :-) It made me look really bad! I took another look, and it seems like the order is wrong, but I still can't figure out how it should actually be written. Could one of you experts help this newbie out? Thanks in advance!
@echo off
echo k >1.txt
if exist 2.txt goto over
if exist 1.txt goto 1
goto end
:1
ren 1.txt 2.txt
ver
c:\password
:end
exit
Floor 2 Posted 2004-09-18 00:00 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
To sysjinglin:
  The main problem is that there is no Goto end after the line ren 1.txt 2.txt; and the goto end above is somewhat redundant.
  Also, this program still has problems in actual use. Asking for a password after being run twice is somewhat like a sharing restriction, but it is not suitable for use as a boot password, because the flaw that a batch file itself can be interrupted is quite serious, and the remedy is also rather troublesome. I suggest using it only for testing.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: