I am trying to create a batch file that plays the beep sound of Bell character. Whenever I try typing Ctrl+G, it triggers the Go To Dialog. I have tried Notepad, Notepad++ and VSCode.
Directly typing echo Ctrl+G
in the command line works but I want to run it through a batch file.
If typing Ctrl+G is not possible, is there any other way of playing that beep sound?
There are many ways to do that
echo echo ^G >bell.bat
(i.e. press Ctrl+G after typing echo echo
then redirect the output to a file) and open bell.bat
in any text editor and continue editing the file07
, select it then open menu Plugins > Converter > HEX -> ASCIIIn PowerShell it's even easier. Simply run [char]7
or print it in any echo command and you'll hear a bell. You can also do that from cmd by running powershell -C [char]7
but it's recommended to use PowerShell instead
In PowerShell you also have [console]::Beep()
or [console]::Beep(frequency, duration)
. For example to beep 2 seconds of A440 run
[console]::Beep(440, 2000)