How to emit sound using built-in speaker from a command line in Windows and Linux?

link|improve this question

50% accept rate
3  
What operating system? – arathorn Jul 24 '09 at 16:08
feedback

4 Answers

up vote 9 down vote accepted

You can call the Win32 MessageBeep operating system function.

On Windows XP or later, type:

rundll32 user32.dll,MessageBeep

I tried it years ago and at first I didn't believe it would work. But that's Microsoft suggested way, as according to their MSDN website:

"...MessageBeep attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker."

link|improve this answer
feedback

With bash on Unix:

echo $'\007'
link|improve this answer
feedback
Echo ^g

where ^ is the ctrl key. Note this doesn't work on Windows 7 - The beep is redirected to the audio system.

link|improve this answer
hey, it works on Windows 7!!!! I think for some motherboards that does not have internal speaker or that it is disabled on sound properties it will not beep. but I tested and functioned!!! but use CTRL instead of "^" character. I don't know the difference, but... – kokbira May 10 '11 at 20:08
feedback

on *nix operating systems

>beep

used to do it.

link|improve this answer
What operating systems were these? – Richard Hoskins Jul 24 '09 at 16:58
You can install this from most debian based linux repositories with sudo apt-get install beep – Charles Ma Jul 25 '09 at 5:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.