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-25 05:06
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » [Help: How to make a batch script that automatically restarts under DOS and counts 50 times] View 1,412 Replies 6
Original Poster Posted 2004-12-31 00:00 ·  中国 广东 深圳 诺瓦科技发展有限公司
初级用户
Credits 109
Posts 3
Joined 2004-12-31 00:00
21-year member
UID 35047
Gender Male
Status Offline
How to make a batch script under DOS that automatically restarts and counts 50 times?
Floor 2 Posted 2005-01-01 00:00 ·  中国 广东 广州 海珠区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Do you mean automatically restarting after a 50-second countdown, or restarting the computer 50 times?
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2005-01-01 00:00 ·  中国 山东 济宁 兖州区 联通
钻石会员
★★★★★
Credits 10,046
Posts 3,039
Joined 2002-11-11 00:00
23-year member
UID 223
Gender Male
Status Offline
Of course it's 50 times backward. Who would use 50 restarts for no reason.
简单就是美
Floor 4 Posted 2005-01-03 00:00 ·  中国 广东 广州 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Hehe, my guess of rebooting 50 times is too naive and ridiculous, right?

In response to the楼主's question:
Just use two programs from the MSDOS 7.1 boot disk: wait.com and shutdown.com. The usage of wait.com is very simple: wait .
In addition, if no key is pressed within the specified time range, an errorlevel value of 0 is returned; otherwise, the ASCII code of the pressed key is returned. Therefore, this batch script can be written like this:
@echo off
echo The computer will reboot in 50 seconds,
echo Press any key to cancel...
wait 50
if not errlevel==0 shutdown r

----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 5 Posted 2005-01-04 00:00 ·  中国 广东 深圳 诺瓦科技发展有限公司
初级用户
Credits 109
Posts 3
Joined 2004-12-31 00:00
21-year member
UID 35047
Gender Male
Status Offline
Thanks! Are there any other methods? I mean, if it's not counting down, but can automatically record the number of its reboots, how should the program be modified? Thanks!
Floor 6 Posted 2005-01-09 00:00 ·  中国 广东 深圳 中移铁通
初级用户
Credits 109
Posts 2
Joined 2004-12-26 00:00
21-year member
UID 34944
Gender Male
Status Offline
Of course there is a way. Note that you must solve one problem: where to record how many times the computer has restarted. My idea is to record this information in a file on the hard disk (such as time.txt). Each time after booting, read the number in this file, and subtract one from this number. Then, find 0 time.txt to judge whether this number of times has reached 0 according to the returned error code. If it is, do not restart again. As for that program that subtracts one each time, we have to write it ourselves, it's not difficult. I've written it. I don't know what other methods everyone has!
Floor 7 Posted 2005-01-10 00:00 ·  中国 广东 深圳 诺瓦科技发展有限公司
初级用户
Credits 105
Posts 1
Joined 2003-06-26 00:00
22-year member
UID 5971
Gender Male
Status Offline
In my memory, I have seen others probably judge like this: 1. First, select the count this DOS external command, increment by one automatically each time it starts, and record it into a file; 2. In order to ensure that it can be recorded normally each time, run a command (I don't remember the specific one) before rebooting, and then judge whether the file it generates exists. If necessary, record the time of reboot, in case there is a basis for querying after the system hangs up. 3. The biggest advantage of writing like this is that there is no need for artificial parameters. For example, if I need an overnight test, I can know when I look in the morning, and it is also relatively flexible. Finally, I can't find the count external command. Is it recommended that the forum collect all DOS internal/external/special DOS commands? I don't know what everyone thinks about this?
Forum Jump: