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"
GOTO:EOF

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%
Output:
**********

_______________
Hope this is useful.