Diriector_Doc
Diriector_Doc

Reputation: 610

Where is the file of the *beep* noise in batch?

I have a batch file with this line of code in it:

choice /c:123 /n

This is basically a glorified pause that only proceeds if 1, 2, or 3 have been pressed. If I press any other button, It will beep. I've search around the internet for the file location of this beep, but I can't find anything.

Where is the file located? How can I get access this sound file?

Upvotes: 2

Views: 3702

Answers (2)

Squashman
Squashman

Reputation: 14290

You can get the beep sound using a little trick with the FORFILES command as documented on DosTips.com

@echo off
setlocal

::Define a Linefeed variable
set LF=^


::above 2 blank lines are critical - do not remove.

call :hexprint "0x07" rtnvar

FOR /L %%L IN (1,1,5) do echo %rtnvar%
pause
exit /b

:hexPrint  string  [rtnVar]
  for /f eol^=^%LF%%LF%^ delims^= %%A in (
    'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"'
  ) do if "%~2" neq "" (set %~2=%%A) else echo(%%A
exit /b

Upvotes: 1

Anders
Anders

Reputation: 101636

Choice.exe imports the Beep function and that is where the sound comes from, it is not a wav file on disk, it is generated dynamically. You can run it in a debugger and set a breakpoint on that function to figure out the exact parameters it is using. On Windows 10 it uses (1500, 500).

Upvotes: 3

Related Questions