How to make the PC speaker beep from the Windows 7 command prompt?

52

15

I'm running some lengthy video encodes using the Handbrake command line interface. After all my encodes are done, I would like to have the PC speaker beep, as I usually turn my large external speakers off.

On Linux I would install the "beep" package, but so far I haven't found such a program for Windows 7.

Possibly related links:

Edit: The question seems to have morphed into "How to make Windows 7 beep the PC speaker?", for which the answer provided by HarryMC is the most appropriate.

oKtosiTe

Posted 2011-01-01T15:14:59.980

Reputation: 7 949

6Ctrl+G>enter gets a system beep in command prompt. Multiples of Ctrl+G gets multiple beeps. – Moab – 2011-01-01T15:41:10.057

@Dennis Williamson: Yes, but I'm using Windows 7 in this case. I'm mostly aware of my options as far as Linux goes. – oKtosiTe – 2011-01-01T17:30:16.830

2@Moab: That doesn't make the PC speaker beep, but the default sound output device. – oKtosiTe – 2011-01-01T17:31:22.447

3Some systems default to the PC speaker if there are no other speakers attached. – Moab – 2011-01-01T18:10:25.793

1@oKtosiTe Interesting. On my computer with PC speaker and 64bit 7, I hear beep from it when using ^G in CMD. – AndrejaKo – 2011-01-01T19:40:53.183

@AndrejaKo: Indeed. I've read some rumors that it depends on the sound chip and its driver. – oKtosiTe – 2011-01-01T21:05:39.197

You could also write a tiny program to do it: BEEP.C: #include <stdio.h>↵ void main() {printf("\b");} – Synetech – 2011-06-27T04:12:11.673

Answers

13

It would help to know whether your Windows 7 is 64-bit or 32-bit.

From Default Beep PC Speaker changed in windows 7 – How to get back to old style :

The default beep is controlled by a driver under, c:\windows\system32\drivers\beep.sys. Maybe if you switched it out with a driver from XP/Vista it would increase the volume.

To see this driver you have to open device manager then click on View > Show hidden devices. Then under Non-Plug and Play Drivers you’ll see “Beep.” This is the driver that runs your beep. Right click on it then choose properties and go to the driver tab, then click on Driver Details… This shows the file version which looks like it’s been change with Windows 7. So replace it with an older version and see what happens.

Procedure to follow :

  1. Boot from an UBCD4WIN disc (or BartPE if you don’t have an SATA hard drive)
  2. Take ownership of the “C:\Windows\System32\Drivers\Beep.sys” file and give the local “Administrators” Group “Full Control” permissions.
  3. Rename “Beep.sys” to “Beep.old” (just in case)
  4. Copy “Beep.sys” from an XP machine to this location.

harrymc

Posted 2011-01-01T15:14:59.980

Reputation: 306 093

1When I tried this on 64-bit Windows 7, it resulted in the "Beep" device not working. Anyone try this on 64-bit? – Jason – 2014-10-29T18:54:31.867

@Jason: Have you tried the beep.sys from a 64-bit XP/Vista? – harrymc – 2014-10-29T19:16:00.513

@harrymc No, but the Microsoft Support article implies 64-bit Vista would not work. Finding a 64-bit XP system is like searching for a unicorn. – Jason – 2014-10-29T23:36:26.820

@Jason: It is to be found in unicorn here (first time I use this file-sharing website). Let me know if it worked (or not).

– harrymc – 2014-10-30T08:12:31.853

@harrymc Thank you for the effort, but the result is the same: This device is either not present, not working properly, or does not have all the drivers installed. (Code 24) – Jason – 2014-10-30T15:50:06.447

1@Jason: Probably a problem with driver signing that prevents unsigned XP drivers from working on Windows 7 64-bit. This solution is therefore not applicable to Windows 7 or later 64-bit versions. – harrymc – 2014-10-30T16:47:46.017

The Windows 7 I'm working on is 32 bit. Will try to swap beep.sys out with the one from Windows XP. – oKtosiTe – 2011-01-07T12:26:43.433

Luckily I dual boot with XP and Arch Linux, so I think I can skip over the Live CD bit. :-) – oKtosiTe – 2011-01-07T12:33:50.943

26

In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.

(source) (An article on why) For those who can't be bothered to read: It was to reduce manufacturing cost

But if you are content with having the beep come out of your speakers a simple batch file can do it.

You can write a DOS batch file that beeps by doing the following: at the DOS prompt type:
echo @echo (Alt-7)>beep.bat

but instead of typing the characters: "(Alt-7)", you hold down the Alt key and press 7 on the numeric keypad. Don't use the 7 on the qwerty part of the keyboard, it has to be on the keypad, and Num Lock has to be on.

(source)

Nifle

Posted 2011-01-01T15:14:59.980

Reputation: 31 337

Don't try doing this under cmder either .. open up a good old fashioned naked cmd.exe – Tim Barrass – 2016-01-25T16:50:42.017

@sandos in Emacs press C-q C-g to insert a BEL character. – Michel de Ruiter – 2018-04-10T07:56:04.307

C:<CTRL+G><enter> will Beep every time, or in newer versions, issue the Windows default error sound. I replace my windows default error sound with a nice smooth 808 kick drum so there's positive reinforcement.

The old Windows Beep sound, which was probably full-volume 1-bit PCM, most likely violated OSHA standards for maximum volume for human ears. That sound, repeatedly, would certainly damage a human's ears, at minimum it would cause that band of the frequency spectrum to die out faster during their lifespan. This is anecdotal, but logical af. – Jordan Stefanelli – 2019-11-14T18:27:09.683

2Sadly, I'm not content with having the beep come out of the speakers. – oKtosiTe – 2011-01-01T16:14:04.180

@oKtosiTe - Then you're probably out of luck – Nifle – 2011-01-01T16:23:17.570

1Is there any alternative to the numpad for the Alt-7? I only have a laptop and no numpad. – Cajunluke – 2011-01-02T13:58:34.900

@Cajun - Use the On-Screen Keyboard that is included in windows, but make sure you hit the Options key (on the on-screen keyboard) and turn on the Numpad – Nifle – 2011-01-02T15:46:13.987

4

@CajunLuke, yes, don’t use the Alt-key combo at all for ASCII control codes (1-31), just press Ctrl+G; that’s the Ctrl-key combo for BEL.

– Synetech – 2011-06-27T04:12:33.843

This does not work if you are in emacs, sadly – sandos – 2011-10-04T08:40:11.380

3On my Win7 box, I NEED to use ALT-007, not ALT-7. – Cameron – 2013-12-09T19:51:32.707

9

If you have python 2.x installed this line in a bat-file works

python -c "print '\7'"

lgwest

Posted 2011-01-01T15:14:59.980

Reputation: 225

3Since print is a function in python 3.x, python -c "print('\7')" should work. – Max Truxa – 2014-09-09T07:08:53.760

Doing this on Windows 10 makes my speakers play the Windows error sound. The beep does not come from the motherboard. :( – DaveTheMinion – 2017-05-28T23:23:37.480

Alternative with Perl: perl -e "print qq(\x07)". If you have strawberryperl portable, you can use portableshell.bat -e "print qq(\x07)" – Benoit – 2018-09-07T12:46:27.373

I had my Sound Scheme set to No Sounds and was wondering why I wasn't hearing anything. Make sure to have a sound scheme with an audible error sound. – mic – 2019-08-06T20:19:37.593

I get "SyntaxError: invalid syntax" when I try this with Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32 – Adriaan Koster – 2013-10-03T11:21:23.397

7

Try start'ing a fake file that doesn't exist. That makes both a popup and the beep sound, but I'm not sure if you want the popup or not...

enter image description here

KenshinHeng

Posted 2011-01-01T15:14:59.980

Reputation: 79

2Edited the answer to clarify; added an image to show how it works. – bwDraco – 2015-05-08T23:48:54.317

6Unfortunately, this won't generate a beep from the PC speaker if there is an actual sound device. It would be necessary to disable the sound device in Windows. – bwDraco – 2015-05-08T23:57:42.787

5

This little VDD driver fixes a problem with the Windows 7 NTVDM where the PC Speaker output is not wrapped correctly.

This may be due to the fact that the functionality of the BEEP.SYS System driver was moved to the Usermode Sound Agent. For further information, see the blog of Larry Osterman.

This driver tries to fix the problem by hooking the NTVDM-Function responsible for the Beep (LazyBeep) and replaces it with our own implementation that has various options to fix the problem.

http://www.waldbauer.com/tmp/dl.php?download=beepx

canopee

Posted 2011-01-01T15:14:59.980

Reputation: 51

1

And for x64 version, try: http://www.waldbauer.com/tmp/dl.php?download=beepxp64

– rustyx – 2017-04-26T08:25:19.500

RustyX Thank you so much!! This was the only thing that finally worked! Beautiful! My UPS alarm is working again! All praise beepxp64. – Zdenek – 2017-09-15T18:19:22.357

There was a virus in the download link on the target page!!! – ellockie – 2013-12-16T13:28:36.417

Some virus scans are giving positives on the download, but due to the nature of the program these could be false positives. The source code is included, so everyone is free to check it out as well if they are unsure. – slhck – 2013-12-29T10:25:18.260

1

The following seems to work on windows systems with py2 & 3:

cmd line:

python -c "import winsound; winsound.PlaySound('SystemExit', winsound.SND_ALIAS);"

Docs

Pedro Lobito

Posted 2011-01-01T15:14:59.980

Reputation: 573

1

Grab NirCmd and run nircmd stdbeep.

digitxp

Posted 2011-01-01T15:14:59.980

Reputation: 13 502

1nircmd beep 1000 1000 does what you want on my computer where beep uses the soundcard (try also nircmdc beep 440 1000). Can anyone with more reputation post an answer based on this? – Aur Saraf – 2018-05-13T18:44:42.927

3I'm afraid that makes the default speakers beep, not the PC speaker. – oKtosiTe – 2011-01-01T16:18:11.070

1

Are you sure it's enabled?

– digitxp – 2011-01-01T17:56:45.860

@digitxp: The BIOS beep and the ability to issue beeps from the Linux console lead me to believe it is, but you raise a valid point. I will investigate. – oKtosiTe – 2011-01-01T21:08:14.420

As far as I can tell, it's enabled in every possible way. – oKtosiTe – 2011-01-01T21:15:31.070

@oKTos Can you make it beep anyhow? – digitxp – 2011-01-01T23:32:17.240

@digitxp: Under Windows XP and Arch Linux: yes. Under Windows 7, so far: no. – oKtosiTe – 2011-01-02T02:14:17.297

3I agree with oKtosiTe; nircmd plays the beep sound through the sound card, NOT the internal speaker; even in XP. From NIRCMD.CHM: Plays the standard beep of Windows. – Synetech – 2011-06-26T18:56:22.900

1

The answer of "canopee" is THE answer! That driver he links to, is the only one getting the beep() back for windows 7 64bit. I tried it and can confirm that it's working like a charm.

Alternatively you might consider downloading "buzzer.exe" from http://encode.ru/threads/383-A-command-line-tool-for-Windows-which-beeps-through-the-System-Speaker as well, which helps using the pc-speaker from commandline even more. It supports custom frequencies and repeatings.

I am not connected to waldbauer.com or encode.ru in any way, i was just searching for a solution to the missing beep, found it, and wanted to help "spread the word"!.. o)

Robert G.

Posted 2011-01-01T15:14:59.980

Reputation: 11

0

If you turn off your external speakers, you don't use them for anything else. So you can also just disconnect them from your computer so the beep command goes through the PC speaker. No extra software or driver transplants required. You just need to remember to reconnect them afterwards.

Nzall

Posted 2011-01-01T15:14:59.980

Reputation: 2 585

1Disconnecting the speakers doesn't make the sound go through the PC speaker. Windows 7 doesn't even normally address the PC speaker anymore, as has been pointed out in some of the other answers and comments. Besides, I do use them on a regular basis, just not 100% of the time. – oKtosiTe – 2014-01-22T21:32:04.073

Not that it matters anymore. The PC in question has since died and I now use an ultrabook on a daily basis, which does not have a dedicated PC speaker. Instead I now use a set of desktop speakers (3.5mm) for notifications and most games and the large, wall-mounted speakers (HDMI) for music and movies. – oKtosiTe – 2014-01-22T21:33:47.670