中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 12:06
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS学习入门 & 精彩文章 (教学室) » [Help: How to make a batch script that automatically restarts under DOS and counts 50 times]
Printable Version  1,511 / 6
Floor1 tonny7919 Posted 2004-12-31 00:00
初级用户 Posts 3 Credits 109
How to make a batch script under DOS that automatically restarts and counts 50 times?
Floor2 JonePeng Posted 2005-01-01 00:00
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
Do you mean automatically restarting after a 50-second countdown, or restarting the computer 50 times?
Floor3 Michael Posted 2005-01-01 00:00
钻石会员 Posts 3,041 Credits 10,056
Of course it's 50 times backward. Who would use 50 restarts for no reason.
Floor4 JonePeng Posted 2005-01-03 00:00
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
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

Floor5 tonny7919 Posted 2005-01-04 00:00
初级用户 Posts 3 Credits 109
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!
Floor6 marshma Posted 2005-01-09 00:00
初级用户 Posts 2 Credits 109
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!
Floor7 hu_niao Posted 2005-01-10 00:00
初级用户 Posts 1 Credits 105
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?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023