windowsbatch-filecygwin

How to start a system "beep", from the built-in pc speaker, using a batch file?


I have written an interactive batch script where tasks sometimes take a long time to complete. After each task, the script prompts the user to decide whether to proceed to the next task, return to the main menu, or something else.

I would like to add an "Interactive Alarm" command that makes a small, short beep (like the one heard when turning on a PC) to alert the user of new questions.

Requirements:

Notes:

Is this possible, and how can it be implemented?


Solution

  • It's not possible to type the BEL directly in (for example) notepad.

    To get it, type echo ^G>>yourbatch.bat on the command line (don't type ^ G, but <Control>-G, which will be shown as ^G on the screen). That puts a strange looking character to the end of your file. That's the BELcharacter 0x007 ("control-G"). Just copy/move it to any echo command, you like. Also

    set /p "input=^Ggive value: "
    

    is possible (where the ^G represents that strange char)