ex.
Code: Select all
Script Name
-----------
Moderator: DosItHelp
Code: Select all
Script Name
-----------
Code: Select all
@echo off
echo Script Name
call :MakeUnderscore 11
echo,
echo Hello World
pause
exit /b
:MakeUnderscore
for /l %%i in (1,1,%1) do (
set /p =-<nul
)
Code: Select all
@echo off
call :MakeUnderscore "Script Name"
echo,
echo Hello World
pause
exit /b
:MakeUnderscore
echo,%~1
for /f "skip=1 delims=:" %%a in ('^(echo "%~1"^&echo.^)^|findstr /o ".*"') do (
set /a StrLen=%%a-5
)
for /l %%i in (1,1,%StrLen%) do (
set /p =-<nul
)
Code: Select all
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set "hiddenChars=----------------------------------------------------------------------------------------------------"
set "string=Hello World"
call :strLen "%string%" out
echo %string%
echo !hiddenChars:~0,%out%!
pause & exit
:strLen
(
set "str=X%~1"
set "length=0"
for /l %%b in (10,-1,0) do (
set /a "length|=1<<%%b"
for %%c in (!length!) do if "!str:~%%c,1!" equ "" (
set /a "length&=~1<<%%b"
)
)
)
IF "%~2" NEQ "" SET /a %~2=%length%
EXIT /b