How do I display elapsed time in a pop up window?

I have the following in a batch script:

REM Launch the message "window"
start "** RUNNING **" m.bat

The m.bat file looks like this:

@echo off
cls
echo ****************************************
echo ****************************************
echo ****     BATCH PROCESS RUNNING      ****
echo ****            DO NOT END          ****
echo ****************************************
echo ****************************************
pause > null
exit
     

I would like somehow to display the elapsed time as well.
In other words how much time has gone by from when the script was run?
A count up timer, ie   2 minutes, 45 seconds.. and it keeps counting up.
100questionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
On which OS, and is it important/required that the script can be closed by pressing a key?
The "m" script could probably even monitor the main script and then end itself when the main script ends, but for that, you need to provide more information about the calling script.
In the meantime, how about something like this (it uses choice.exe; should be part of Windows since Vista):
@echo off
setlocal
set /a Interval = 5
set /a Seconds = 0
:Loop
cls
echo ****************************************
echo ****************************************
echo ****     BATCH PROCESS RUNNING      ****
echo ****            DO NOT END          ****
echo ****************************************
echo ****************************************
echo ** RUNNING for %Seconds% seconds **
set /a Seconds += Interval
choice.exe /t 5 /d C /n /c CX >NUL
if %errorlevel%==1 (
	title ** RUNNING for %Seconds% seconds **
	goto Loop
)
exit /b

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
100questionsAuthor Commented:
Thank you.  
OS is Windows 8.
Another script which runs will need to kill the m.bat process.
It looks like at the moment that script does not kill the process however, and the m.bat just keeps running and running.

My other script had this near the end of the script which would kill the m.bat script, however this no longer works:

REM Find and kill the message proc
for /f "tokens=2 delims=," %%A in ('tasklist /v /fo csv ^| find "** RUNNING **"') do (
  taskkill /pid %%~A > nul
)

Any suggestions?

Thanks in advance.
0
oBdACommented:
Then the other script probably looks for Window title, which I used to display the remaining time as well.
Remove line 17 and try again.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

100questionsAuthor Commented:
Works well now. Thank you.
0
Steve KnightIT ConsultancyCommented:
Sometimes useful to add a change of window size and color too if wanted, add something like this below @echo off:

mode 45,10
color 4f

color  /? shows you color possibilities.  mode is cols,rows

Steve
0
100questionsAuthor Commented:
Thanks dragon-it, very useful features.   I tried it and it works well.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.