Computing.Net > Forums > Programming > Dos Scripting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dos Scripting

Reply to Message Icon

Name: X-TechKid
Date: November 2, 2009 at 22:52:38 Pacific
OS: Windows XP
Subcategory: General
Tags: DOS, date, calculations date
Comment:

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
pause

Ive 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 :-)



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: November 3, 2009 at 02:08:26 Pacific
Reply:

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.


1

Response Number 2
Name: X-TechKid
Date: November 3, 2009 at 17:51:00 Pacific
Reply:

Thanks klint, am sorry abt the title.
Ur response was helpful.

Regards

X-TechKid
Keep Smiling :-)

[Edited HTML to un-break tables - Razor2.3]


1

Response Number 3
Name: nbrane
Date: November 6, 2009 at 23:57:50 Pacific
Reply:

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.


1

Response Number 4
Name: Razor2.3
Date: November 8, 2009 at 12:07:18 Pacific
Reply:

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


0

Response Number 5
Name: X-TechKid
Date: November 8, 2009 at 21:49:44 Pacific
Reply:

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..


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: November 8, 2009 at 22:09:30 Pacific
Reply:

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().


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Dos Scripting

Telnet in DOS scripts www.computing.net/answers/programming/telnet-in-dos-scripts/9238.html

DOS Script File www.computing.net/answers/programming/dos-script-file/12664.html

Dos script run in the background www.computing.net/answers/programming/dos-script-run-in-the-background/14605.html