中国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-09-15 12:59
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » Please provide more context or details about what specific kind of timing functionality you need in the batch script, like whether it's counting elapsed time, timing a specific operation, etc. So that I can accurately help you create a suitable batch script.
Printable Version  3,961 / 18
Floor1 eech Posted 2007-01-19 12:17
高级用户 Posts 346 Credits 906
For example, a batch processing starting from 00:00:01
Floor2 PPdos Posted 2007-01-19 20:58
高级用户 Posts 268 Credits 783
Rem Save the file name as the time you want to set. For example, now it's 11:35:21 and you want to set it to run at 11:36.
Rem Then change the file name "Timer.bat" to 1136.bat (precise to minutes, fill the file name to 4 digits)
@echo off&title Timer&color 0D
mode con cols=15 lines=3&set l=%time: =0%&set n=%l::=%
if "%n:~0,-5%"=="%~n0" start mshta vbscript:CreateObject("SAPI.SpVoice").Speak("sorry Your time is limited!")(Window.close)&msg %username% Sorry your time is limited!
ping 127.0|set /p l= %time:~0,-3%&cls&%0
Msgbox "Sorry your time is limited"

Attachments
定时器.rar (487 bytes)
Floor3 boluor Posted 2007-01-19 21:44
初级用户 Posts 54 Credits 129 From 武大信息学部
It seems to change every three seconds, which is pretty good. But what's the use of you putting that "your time is limited"? It made me think I was modifying the time on my computer, and then a real-time debugging dialog box appeared on the computer again.....
Floor4 everest79 Posted 2007-01-19 21:59
金牌会员 Posts 1,127 Credits 2,564
Let's see... The user provided a batch code snippet and wants it translated if needed. But the code is already in English in terms of the programming logic. Wait, no, the original Chinese was "试试看" which is "Let's try it". Then the code is as given. So the translated text would be:

Let's try it

Floor5 PPdos Posted 2007-01-19 22:08
高级用户 Posts 268 Credits 783


-n changed to 2, initialized parameter to 0, done

[ Last edited by PPdos on 2007-1-24 at 11:52 PM ]

Attachments
计时器.rar (274 bytes)
Floor6 boluor Posted 2007-01-19 22:18
初级用户 Posts 54 Credits 129 From 武大信息学部
Sure, but there's no Chinese content here that needs translation. The text you provided is already in Chinese but the relevant part "果然是高啊....顶上来!!!!!!!!!!!" when translated literally is "Sure is high.... Push up!!!!!!!!!!!" But if we consider it's just an expression, maybe it's better to keep it as is if no translation is needed. Wait, actually, the task is to translate Chinese to English. But this is an exclamation. Let me rephrase: "Sure is clever.... Push it up!!!!!!!!!!!" But maybe a more natural way is "That's really smart.... Bump it up!!!!!!!!!!!"
Floor7 everest79 Posted 2007-01-19 22:57
金牌会员 Posts 1,127 Credits 2,564
My time is either long or there's an issue. It has been running here for nearly an hour and then suddenly exited. Stable operation is with a memory usage of 588k, the time is correct, but it seems there's still some problem with the calculation.
Floor8 PPdos Posted 2007-01-19 23:31
高级用户 Posts 268 Credits 783
The disadvantage of using the timer of ping is that it is inaccurate but the speed of timing can be changed by modifying parameters. And the timer refreshes the screen through the delay of ping to display the changed time. No matter whether the refresh is fast or slow, the accuracy of time has not changed. But if the refresh is too fast, the problem of excessive memory occupation will also occur. So in the above program, the memory consumption is minimized as much as possible. There are many ideas from the forum infiltrated in the program. (Forgot to delete after Msgbox test)
Floor9 eech Posted 2007-01-20 01:14
高级用户 Posts 346 Credits 906
Thanks everyone. I tried. It seems a bit slow. Hehe.
Floor10 tashaxin Posted 2007-01-25 10:41
初级用户 Posts 30 Credits 99
Floor11 jackyggt Posted 2007-03-16 07:49
初级用户 Posts 38 Credits 76
Good
Floor12 liu3157551 Posted 2007-03-22 14:55
中级用户 Posts 164 Credits 259
The post on the 5th floor is quite good! His approach is worth my learning! Because he uploaded and shared the successful results with others! 2007-3-22 1:46:41 Thursday
Floor13 zhoushijay Posted 2007-03-23 01:49
高级用户 Posts 375 Credits 845
@echo off
echo Please press any key to start timing...
pause>nul


set a=0
set b=0
set c=0
:start
cls
echo Timing: %a%:%b%:%c%

set /a c+=1
if %c%==60 (set c=0
set /a b+=1
)
if %b%==60 (set b=0
set /a a+=1
)
ping -n 1 127.1>nul 2>nul
goto :start

Not fully tested, heh
Floor14 pmwz008 Posted 2007-03-23 05:18
初级用户 Posts 13 Credits 24
Sure enough, it's really clever.... Push it up
Floor15 penghuahui Posted 2007-12-05 13:40
初级用户 Posts 86 Credits 163
Learned
Expert!
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023