Here's an example of a windowsbatch-file which doesn't do what your example is demonstrating, but does something I think you may prefer instead:
@Set "TextString=This is my text string!"
@For /F %%G In ('"Prompt $H&For %%H In (1) Do Rem"') Do @Set "BS=%%G"
@(For /F Delims^=^ EOL^= %%G In ('(%SystemRoot%\System32\cmd.exe /D /S ^
/U /V /C "Echo=!TextString!"^) ^| %SystemRoot%\System32\find.exe /V ""'
) Do @Set /P "=.%BS%%%G" 0< NUL & %SystemRoot%\System32\PATHPING.EXE ^
127.0.0.1 -n -q 1 -p 150 1> NUL) & Echo=
@Pause
You simply place your required text to be printed, into the first line (between the =
and closing "
), and double-click it to run and view. If the intent is to run the script directly from cmd, you do not need the last line, @Pause
, and can safely remove it.
As a result of a comment, I have decided to present the code in a slightly different way, so that it can be reused for different strings.
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
For /F %%G In ('"Prompt $H&For %%H In (1) Do Rem"') Do Set "BS=%%G"
Set "TextString=This is my text string!"
Call :GhostTypeIt
Set "TextString=This is "another" string."
Call :GhostTypeIt
Set "TextString=This & That are <words>."
Call :GhostTypeIt
Pause
Exit /B
:GhostTypeIt
(For /F Delims^=^ EOL^= %%G In ('(%SystemRoot%\System32\cmd.exe /D /S ^
/U /V /C "Echo=!TextString!"^) ^| %SystemRoot%\System32\find.exe /V ""'
) Do Set /P "=.%BS%%%G" 0< NUL & %SystemRoot%\System32\PATHPING.EXE ^
127.0.0.1 -n -q 1 -p 150 1> NUL) & Echo=
GoTo :EOF