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-07-31 23:34
中国DOS联盟论坛 » 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. View 3,603 Replies 18
Original Poster Posted 2007-01-19 12:17 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
20-year member
UID 58334
Gender Male
Status Offline
For example, a batch processing starting from 00:00:01
Floor 2 Posted 2007-01-19 20:58 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
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"
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
redtek +5 2007-01-19 21:41
axi +2 2007-03-16 11:58
Attachments
定时器.rar (487 bytes, Credits to download 1 pts, Downloads: 139)
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 3 Posted 2007-01-19 21:44 ·  中国 湖北 武汉 教育网
初级用户
★★
Credits 129
Posts 54
Joined 2007-01-04 01:03
19-year member
UID 75376
Gender Male
From 武大信息学部
Status Offline
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.....
Floor 4 Posted 2007-01-19 21:59 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
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


@ECHO OFF
SET TIMEON=%TIME:~0,-3%
:TIME1
SET /A S9=%TIME:~7,1%,S1+=S
SET /A H=S1/3600,M=S1%%3600/60,S=S1%%3600%%60
CLS&ECHO stopwatch %H%:%M%:%S% current:%TIME:~0,-3% timeon:%TIMEON% secs=%S1% %S9%
::SET /A S1/(S1-100000) 2>nul||GOTO NEXT
:TIME0
SET /A S=(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10)/(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10-1)
GOTO TIME%S%

Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
qzwqzw +7 2007-02-01 11:21
Floor 5 Posted 2007-01-19 22:08 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
@echo off&mode con cols=20 lines=20
title Timer&color 0D
set /a H=0,M=0,S=0
set /a H=%t%%%86400/3600 2>nul
set /a M=%t%%%86400%%3600/60 2>nul
set /a S=%t%%%86400%%3600%%60 2>nul
@ping -n 2 127.0|set/p l=Elapsed time: %H%:%M%:%S%&set /a t+=1&cls&%0


-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, Credits to download 1 pts, Downloads: 73)
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 6 Posted 2007-01-19 22:18 ·  中国 湖北 武汉 教育网
初级用户
★★
Credits 129
Posts 54
Joined 2007-01-04 01:03
19-year member
UID 75376
Gender Male
From 武大信息学部
Status Offline
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!!!!!!!!!!!"
Floor 7 Posted 2007-01-19 22:57 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
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.
Floor 8 Posted 2007-01-19 23:31 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
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)
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 9 Posted 2007-01-20 01:14 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
20-year member
UID 58334
Gender Male
Status Offline
Thanks everyone. I tried. It seems a bit slow. Hehe.
Floor 10 Posted 2007-01-25 10:41 ·  中国 广东 佛山 顺德区 电信
初级用户
Credits 99
Posts 30
Joined 2007-01-19 05:46
19-year member
UID 76980
Gender Male
Status Offline
Floor 11 Posted 2007-03-16 07:49 ·  中国 湖北 武汉 江夏区 电信
初级用户
Credits 76
Posts 38
Joined 2007-03-13 02:54
19-year member
UID 81544
Gender Male
Status Offline
Good
Floor 12 Posted 2007-03-22 14:55 ·  中国 广西 南宁 西乡塘区 电信
中级用户
★★
Credits 259
Posts 164
Joined 2006-09-21 23:39
19-year member
UID 63296
Status Offline
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
Floor 13 Posted 2007-03-23 01:49 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
@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
Floor 14 Posted 2007-03-23 05:18 ·  中国 贵州 六盘水 移动
初级用户
Credits 24
Posts 13
Joined 2007-03-23 04:55
19-year member
UID 82620
Gender Male
Status Offline
Sure enough, it's really clever.... Push it up
Floor 15 Posted 2007-12-05 13:40 ·  中国 广东 广州 教育网
初级用户
★★
Credits 163
Posts 86
Joined 2007-09-05 03:02
18-year member
UID 96588
Gender Male
Status Offline
Learned
Expert!
Forum Jump: