How to emit sound using built-in speaker from a command line in Windows and Linux?
You can call the Win32 MessageBeep operating system function.
On Windows XP or later, type:
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."