Page 1 of 1

Showing a continuous countdown while executing other commands in background

Posted: 13 Oct 2023 10:50
by DOSadnie
Is it possible at all using just a single window created by BAT or PS1 script to see one rather long countdown while in the background the very same file will be firing up other commands? And if the user decided to interrupt the whole process to be able to close that window thus effectively stopping whatever commands are left from being ever executed?

Or will I have to use some e.g. AHK script that will show me a Windows Console window containing just a countdown, and which AHK script upon detecting closure of closure of that window will stop further instructions of this AHK?

Re: Showing a continuous countdown while executing other commands in background

Posted: 13 Oct 2023 11:22
by miskox
You could use a progress bar. See:

viewtopic.php?t=5503
with this:
viewtopic.php?p=33575#p33575

Now Escape sequences should be used instead of an .exe.

viewtopic.php?t=3495
viewtopic.php?t=10400
viewtopic.php?t=274

You could also add this info to the Console Window's Title

Saso

Re: Showing a continuous countdown while executing other commands in background

Posted: 16 Oct 2023 11:05
by DOSadnie
I see there are some options in doing this, thank you

But as they seem too complex for my limited skills, for now I will most likely be using something simple as this:

Code: Select all

@echo off
setlocal enabledelayedexpansion

:: Set the length of the countdown:
set LENGTH_OF_THE_INITIAL_COUNTDOWN=2

:: Initial message:
echo.
echo.   C O M M E N C I N G   T H E   S C R I P T :
echo.
echo.   Press any key to cancel
echo.   

:: Check if the output ends with zero that is not preceded by another digit:
timeout /t %LENGTH_OF_THE_INITIAL_COUNTDOWN% >nul 2>nul

:: Terminate this script if no trailing 0 is found:
if errorlevel 1 exit /b

:: Place for other commands that are to be executed after the countdown:

set "STEADY_NON_FLASHING_MESSAGE=   E X E C U T I N G :"
echo.
echo.
echo.!STEADY_NON_FLASHING_MESSAGE!
echo.   

timeout /t 1 >nul 2>nul

:: Calculator:
echo.   ^> Calculator
echo.   
timeout /t 1 >nul 2>nul
start "" /b /min calc.exe

:: Microsoft Screen Magnifier:
echo.   ^> Magnifier
echo. 
timeout /t 1 >nul 2>nul
start "" /b magnify.exe

:: Notepad:
echo.   ^> Notepad
echo.   
timeout /t 1 >nul 2>nul
start "" /b /min notepad.exe

:: Accessibility On-Screen Keyboard:
echo.   ^> Virtual Keyboard
echo.   
timeout /t 1 >nul 2>nul
start "" /b osk.exe

:: Closing message:
set "END_MESSAGE=   T H E   E N D :"
echo.
echo.
echo.!END_MESSAGE!
echo.
echo.   Finished executing the script
echo.

:: End the script:
pause >nul
:: timeout /t 3 >nul 2>nul
:: exit /b
which I reckon in time I will be able expand into having an indicator of how many executions are listed in the file and which one is taking place in a given moment