中国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-05 04:22
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Are there any more clever techniques for batch processing delays?
Printable Version  33,563 / 71
Floor1 nvflash Posted 2006-09-29 07:08
初级用户 Posts 38 Credits 126
ping -n can achieve delay, but I recognize this is not a good way, because I checked the CPU usage, and when pinging, it has reached 50%. Such a delay, what program are you going to do?
Floor2 vkill Posted 2006-09-29 07:41
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
可以变通一下,用 at

Can be flexibly handled, using "at"
Floor3 nvflash Posted 2006-09-29 07:47
初级用户 Posts 38 Credits 126
It seems that at requires the support of a service. Now many machines, after optimization, have not enabled this service.
Floor4 vkill Posted 2006-09-29 07:54
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Originally posted by nvflash at 2006-9-29 07:47:
at seems to require service support. Now many machines are optimized and this service is not enabled

You can just enable it on your own machine~ If you want to enable it on someone else's machine, you can execute the following to enable it

sc config schedule start= auto
sc start schedule
Floor5 nvflash Posted 2006-09-29 08:17
初级用户 Posts 38 Credits 126
If you say it's about task scheduling, I've lost confidence. I've tried multiple task scheduling methods many times, and it inexplicably didn't execute correctly. This thing isn't very reliable, I think it's better not to use it.
Floor6 vkill Posted 2006-09-29 08:19
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Hehe, it is suggested that you search for "delay" as there have been many discussions about it before
Floor7 3742668 Posted 2006-09-29 08:48
荣誉版主 Posts 718 Credits 2,013
Summary of Batch Processing Delay Methods:

1. ping

Memory Usage: cmd.exe 1704k
ping.exe 2920k
Error Evaluation: High
Advantages: Simple code structure
Disadvantages: High memory usage, relatively large error when delay time is long

2. Still ping

Memory Usage: cmd.exe 1700k
ping.exe 2912k
Error Evaluation: General
Advantages: Simple code structure, smaller error with longer time, higher accuracy (50ms)
Disadvantages: High memory usage


3. call

Memory Usage: cmd.exe 1744k
cmd.exe 1740k
Error Evaluation: Very high (greatly affected by CPU frequency, almost impossible to accurately grasp overall delay time)
Advantages: Relatively high accuracy
Disadvantages: Not suitable for occasions requiring precise time grasping

4. msg

Memory Usage: cmd.exe 1752k
msg.exe 2620k
Error Evaluation: Low
Advantages: Relatively stable, can cancel delay midway, simple code structure
Disadvantages: Very high memory usage, window pops up (advantage? Disadvantage?)

5. vbs

Memory Usage: cscript.exe 4812k
cmd.exe 1708k
Error Evaluation: Very low
Advantages: Highest accuracy, more flexible and convenient to use
Disadvantages: Temporary file generated, high memory usage


End:
1. Limited test conditions, the above data is not authoritative.
2. About accuracy.
Actually, any command with adjustable time has relatively high accuracy, the reason for being affected depends on the number of command executions, the more times, the lower the accuracy. And the reason why the fifth scheme is said to have the highest accuracy can be exemplified: cscript //b //nologo delay.vbs 2036, while the second scheme is still worse than the fifth scheme due to the minimum accuracy.
3. Everyone is welcome to supplement.
Reference Links:
1.Trouble Caused by a GIF File
2. Heterodoxy in Batch Processing Programming


[ Last edited by 3742668 on 2006-9-29 at 08:49 ]
Floor8 redtek Posted 2006-09-29 08:49
金牌会员 Posts 1,147 Credits 2,902
Can you explain why you need to perform a delay operation?
Floor9 nvflash Posted 2006-09-29 09:11
初级用户 Posts 38 Credits 126
Excuse me, moderator, besides %time%, what other system-built-in variables are there?
Floor10 3742668 Posted 2006-09-29 09:14
荣誉版主 Posts 718 Credits 2,013
Originally posted by nvflash at 2006-9-29 09:11:
May I ask the moderator, besides %time%, what are other system-built-in variables?

1. Run the command set without parameters
2. Run the command set /?, at the end.
Floor11 asbai Posted 2006-11-03 12:40
高级用户 Posts 252 Credits 653
Recommend a standard POSIX command: sleep, for example:

Sleep for 10 seconds
sleep 10s

1 minute
sleep 1m

2 hours
sleep 2h

5 days:
sleep 5d

The attachment is the win32 version of sleep. It may be not very convenient for batch processing that needs to be spread around. It's good for personal use.

Attachments
sleep.rar (7.57 KiB)
Floor12 lxmxn Posted 2006-11-03 23:43
版主 Posts 4,938 Credits 11,386

  Hehe, thanks to the person above for providing another small tool for delaying. I'll download it and try it out~~

  I remember there's another tool called sleepx, which can be precise to milliseconds. I wonder if this sleep has relatively high precision~~
Floor13 asbai Posted 2006-11-04 04:25
高级用户 Posts 252 Credits 653
Originally posted by lxmxn at 2006-11-3 23:43:

  Hehe, thank you upstairs for providing another small tool for delay. Download it and try it~~

  I remember there is another tool called sleepx, which can be precise to milliseconds. I wonder this sle ...


Hehe, under win32, except for using the API: timeSetEvent, it is very difficult for other means to achieve precise millisecond-level delays (although Performance Counter can also do it, but the CPU utilization rate is too high).

timeSetEvent will change the time slice granularity in the global system range, and also has a little impact on system performance. If you think it is really necessary, I can write one
Floor14 scriptor Posted 2006-12-26 07:40
银牌会员 Posts 555 Credits 1,187
This is good.
Support
Floor15 PPdos Posted 2006-12-26 19:20
高级用户 Posts 268 Credits 783
@echo off
echo Current seconds: %time:~6,-3%
set /p dalay="Enter the delay in seconds within 60: "%dalay%
:compte
if not "%dalay%"=="%time:~6,-3%" goto compte
echo Time's up!! Pay the bill!
pause>nul
1 2 3 45  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023