Tuesday, May 26, 2015

Beeping from Windows Batch

It may, from time to time, be useful to create a beep or notification sound from a Windows batch file. You could launch some lightweight media player pointed at a simple sound file, but that's way overkill. Just insert ASCII character 7, the control character called BEL (bell). The command processor, when printing text, produces a beep upon encountering that character, printing no visible representation of it.

While typing in a copy con prompt or when echoing to a file, use Control+G to create the character (it will appear as ^G on the command line).

In Notepad and most text editors, hold down the right-hand Alt key while pressing 7 on your numeric keypad (with NumLock on). This will create a character that looks like a big dot.

Your batch file will end up with something like echo •. When the command processor executes this line, a beep will be made. On Windows 8 (and possibly other versions after Windows XP, which I know does the standard DOS-like beep), this actually produces the OS-standard message box sound. Either way, you'll hear something.

No comments:

Post a Comment