Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Am tryin to develop a dos based application for displaying time in the taskbar when the window is minimized. The code goes like this.@echo off
:tl
cls
title %time% - The time machine
@echo The current Time Is..
@echo [**** ]
@echo %time%
ping 127.0.0.1 -n 2 >nul
cls
@echo The current Time Is..
@echo [ ****]
@echo %time%
title %time% - The time machine
ping 127.0.0.1 -n 2 >nul
goto tl
pauseIve been using ping localhost thing to create delay.
1. Is there an alternate way to create delay in batch files
2. I want to change the time by performing calculations on my current system time some thing like %time% -5
Is that possible?
3. Can u suggest me some code to display a progress bar in batch files.. mine is bad :-)

Your title is wrong, DOS is an obsolete 16-bit operating system and not a batch-file command processor. There is no DOS in Windows XP. What you are using is the Win32 Command Processor.
In Windows XP, ping is the de-facto standard way of obtaining a pause, in the absence of external utilities (such as SLEEP.exe from the Windows 2003 Resource Kit which can be freely downloaded from the Microsoft web site).
For the other two questions, it would be much easier to do it in another language, such as VBScript. In fact, in VBScript it would also be much easier to perform a pause (i.e. your first question) too.

Thanks klint, am sorry abt the title.
Ur response was helpful.Regards
X-TechKid
Keep Smiling :-)[Edited HTML to un-break tables - Razor2.3]

routine does timer (example 5 seconds):
replace var. names as suitable
for minutes not seconds, replace: ,8! with ,5!
in code. (hh:mm:ss mins end at 5, secs at 8, hrs at 2):no of seconds to wait
set /a timr=5
echo %timr% wait:
echo go to timer %time%
call :timer
echo back from timer %time%
goto ex:timer
set c=%time%
set c=!c:~0,8!
set /a tz=0
:dd
set d=%timer%
set d=!d:~0,8!
if d neq !c! (
:diagnostic: echo timr= !tiimr! tz= !tz!
set /a tz+=
if !timr! gte !tz! goto ex)
goto dd:ex
:(return or exit)not recommended for serious applications due to overhead, use tsr or trusted "third party app" as suggested above. consult microsoft msdn site. this (above code) kind of junk can slow things down for other users.

I should probably throw in my batch waiting method. Basicaly, it uses VBscript to wait:
echo WScript.Sleep WScript.Arguments(0) * 1000 > sleep.vbs sleep.vbs 5

Hi
Is there any method of creating delay which does not overload the cpu.. coz.. Any application where delay factor is used.. irrespective of the language we use to code.. there is slight overhead to the over all cpu utilization..

there is slight overhead to the over all cpu utilization
Actually, it depends on if the language implements SleepEx(). SleepEX() tells the Windows thread scheduler that the thread/program is illegible to run for the specified time period. For the record, WScript.Sleep uses SleepEX().

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |