Page 1 of 1

Which hex value does "beep" when echoed at the cmdprompt?

Posted: 25 Aug 2014 01:05
by pstein
Sometimes I output lots of text stuff with "Echo" at the cmdline.

And it occurs occasionally that a "beep" can be heared.

So it seems to me that this is a hidden, invisible control char somewhere embedded in the text.

Exactly which hex value causes the command prompt to beep when its echoed from a batch script?

Peter

Re: Which hex value does "beep" when echoed at the cmdprompt

Posted: 25 Aug 2014 02:46
by ShadowThief
07, otherwise known as the Bell character

Re: Which hex value does "beep" when echoed at the cmdprompt

Posted: 25 Aug 2014 09:40
by Yury

Code: Select all

@echo off

forfiles /m "%~nx0" /c "cmd /c echo 0x07"

for /f %%i in ('forfiles /m "%~nx0" /c "cmd /c echo 0x07"') do set BEL=%%i
echo %BEL%



or


Code: Select all

@echo off

mshta "vbscript:CreateObject("Scripting.FileSystemObject").GetStandardStream(1).Write(Chr(7))&Close()"| more

for /f %%i in ('mshta "vbscript:CreateObject("Scripting.FileSystemObject").GetStandardStream(1).Write(Chr(7))&Close()"') do set BEL=%%i
echo %BEL%



.



For Windows 8 (?), Windows 8.1:


Code: Select all

@echo off

forfiles /m "%~nx0" /c "cmd /c echo 0x07"
timeout /t 1 /nobreak>nul

for /f %%i in ('forfiles /m "%~nx0" /c "cmd /c echo 0x07"') do set BEL=%%i
echo %BEL%
timeout /t 1 /nobreak>nul



or


Code: Select all

@echo off

mshta "vbscript:CreateObject("Scripting.FileSystemObject").GetStandardStream(1).Write(Chr(7))&Close()"| more

for /f %%i in ('mshta "vbscript:CreateObject("Scripting.FileSystemObject").GetStandardStream(1).Write(Chr(7))&Close()"') do set BEL=%%i
echo %BEL%
timeout /t 1 /nobreak>nul



.