rundll32.exe Kernel32.dll,Beep 750,300
or
rundll32.exe cmdext.dll,MessageBeepStub
or
rundll32 user32.dll,MessageBeep
With rundll functions you''ll no need special symbols like ^G
. With the first method you can also set the frequency and the time you want to beep.
UPDATE
another options are:
powershell "[console]::beep(500,300)"
or using systemSounds.bat
call systemsounds.bat beep
rundll32.exe Kernel32.dll,Beep 750,300
- this does not work well on modern windows systems as rundll32 no longer accepts integer values through command line and this will play the beep with the default values which is too long (and frequency is irritating)
As the capability of beeping depends also on the mainboard and if the mainboard has a system speaker - which more and more becomes a rarity - the systems more and more depend on the normal speakers. So an option is to play sound through them. Here are some options:
Using the speaking capabilities of the SAPI.SpVoice
:
mshta "javascript:code(close((V=(v=new ActiveXObject('SAPI.SpVoice')).GetVoices()).count&&v.Speak('beep')))"
Here this is wrapped in a batch file and the words can be passed as an argument
SAPI.SpVoice
can be used for playing wav
files and you have some coming with the windows installation.You can use this script:
spplayer.bat "C:WindowsMediaWindows Navigation Start.wav"
Another option - using the windows media player active-x objects to play a sound. On windows XP it was not installed by default but I think for the newer windows versions it is. It also can play mp3
files:
call mediarunner.bat "C:WindowsMediaRing03.wav"
And one a little bit obscure - using the <bgsound>
tag from internet explorer (which also can play mp3 files). Here's the script:
call soundplayer.bat "C:WindowsMediaada.wav"
And here's a way to use the BEL
character to produce sound with easy to copy-paste code (I've called it a beeper.bat
):
@echo off
setlocal
::Define a Linefeed variable
(set LF=^
%=-=%
)
for /f eol^=^%LF%%LF%^ delims^= %%A in (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x07"'
) do echo(%%A