Repeat a character in windows batch

This batch code will repeat a character a number of times.

It works in all modern versions of Windows.

:: CharRepeat
:: Repeats a character a specified number of times.
:: Arguments:
::  %1  ResultVar       The name of the environment variable that is populated
::                      with the result.
::  %2  Character       The character to repeat.
::  %3  Count           The number of times to repeat <character>.
:CharRepeat <resultvar> <character> <count>
SET "%~1="
FOR /L %%I IN (1,1,%~3) DO SET "%~1=!%~1!%~2"

You can use the code like so:

Call :CharRepeat RepeatedChar * 10
ECHO %RepeatedChar%
Call :CharRepeat RepeatedChar " " 10
ECHO %RepeatedChar%
Call :CharRepeat RepeatedChar _ 15
ECHO %RepeatedChar%

Hope this is useful.

Timeout Utility

Update (04/09/2013) – v1.0.2 released.

While working on a batch script for MS-DOS, I was looking for a utility similar to Timeout.exe (originally provided in the NT 4.0 Resource Kit, currently provided with Windows) for Microsoft DOS and the Windows ME version of DOS. I was unable to find anything that suited my needs, so I put one together. This utility compares to Timeout.exe, Wait.exe, Delay.exe and Pause.exe. This allows you to put a timed delay into a batch script without resulting to using tricks with Choice or Ping. The 16-bit version of this application will run on MS-DOS v3.3+, the Windows version will run on any version of Windows. The Linux version should run on any version of Linux.

Timeout v1.0.2
This utility accepts a timeout parameter to wait for the specified time period (in seconds) or until any key is pressed. It also accepts a parameter to ignore the key press.

TIMEOUT [/T timeout] [/NoBreak] [/Q] [/NoLogo]
/?           Displays this help message.
/T, /timeout Specifies the number of seconds to wait.
Valid range is -1 to 99999 seconds.
/NoBreak     Ignore key presses and wait the specified time.
/NoLogo      Does not display application logo.
/Q, /quiet   Does not output any text during execution.

The files can be downloaded here:


This release has been tested on the following Operating Systems:

  • MS-DOS 6.22
  • FreeDOS 1.1
  • DOSBox 0.74
  • Windows 7
  • Windows 8
  • Ubuntu 12.10

Change log:

v1.0.2 – April 9, 2013
– [ADD] (4) Linux support for NosCLU
– [FIX] (6) Logo should not be displayed with Quiet switch
– [FIX] (8) Extra Line is generated running with /q quiet argument
– [FIX] (9) Timeout output can not be logged to a file
– [FIX] (10) Timeout parameter causes Segmentation fault in Linux

v1.0.1 – March 2, 2013
– [FIX] (1) Ctrl+C Combination does not work under MS-DOS

v1.0.0 – February 24, 2013
– Initial Version

Please comment below if you have any comments or suggestions.