CLS (clear) a single line?

Unfortunately, there is no native command or utility that repositions your cursor in a Windows command line console.

You will need a 3rd party utility.

Aacini posted a free CursorPos.exe utility on DOSTips. The CurorPos.exe "source" is given as Hex digits. To use the source you will need the HexToBin.bat "compiler".

Browse both threads and you will find a number of utilities you may find useful.


If you only need to move the cursor in one line (like your sample),
it's possible with a carriage return character.

@echo off
setlocal EnableDelayedExpansion
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
for /L %%n in (5 -1 1) do (
  <nul set /P "=This window will close in %%n seconds!CR!"
  ping -n 2 localhost > nul
)