I am using Windows 7 home edition. I want to make my computer wait a certain amount of time, then beep in warning right before it terminates a program. As a test, I wrote the following batch file to make Windows Media Player play the radio, wait 10 seconds, then beep and turn it off:

@echo off
start "_" "C:\Program Files (x86)\Windows Media Player\wmplayer.exe" "http://www.cpr.org/content_category_templates/listenTemplate/listenClassical48.asx"
sleep 10
@echo ^G
@echo ^G
@echo ^G
@echo ^G
taskkill /im wmplayer.exe /f

Note: following instructions I found in another question on this site, the "^G" thingy is the character you get when you type control + G at a command prompt. It does not seem to appear on this site, so I replaced it with ^G.

This worked perfectly. Until, that is, I attempted to make it run automatically using the Windows Task Scheduler. I tried this several times an it did not beep. The other functions worked fine, but no beep was audible.

The script did not run in a window when started by the task scheduler, and I concluded that this must cause problems with the echo command (nothing to echo to). So, after spending some time searching for a method of causing the beep that did not involve echo, I eventually rewrote the whole thing in the form of a VB .NET console program:

Imports System.Threading

Module Beep

    Sub Main()
        Dim wmp As New System.Diagnostics.Process
        wmp.StartInfo.FileName = "C:\Program Files (x86)\Windows Media Player\wmplayer.exe"
        wmp.StartInfo.Arguments = "http://www.cpr.org/content_category_templates/listenTemplate/listenClassical48.asx"
        wmp.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        Thread.Sleep(New TimeSpan(0, 0, 10))
    End Sub

End Module

This works the same way — including the fact that it only beeps when called manually. When called from the task scheduler, it also fails to beep. I'm not sure what else to try, here. Any help would be appreciated.


It's possible that there's a problem with trying to launch the media player system from a script. You can create a batch script with the Ctrl+G character as you mentioned, and it will use the system beep. I don't think the Ctrl+C method you were talking about actually works.

Open a command prompt, change directories to where you want to save the batch file, and type the following commands:

copy con beep.cmd

Ctrl+G, Ctrl+Z

Now, if you run beep.cmd, it should use the system beep.

I created a system task to run this batch file, and when I run the task manually, the command window appears and beeps, then exits.

The way this works is that it copies whatever you type in the command window into the specified file, in this case beep.cmd. You can't just put in ^G in the file, even though that's what appears on screen, because typing that is really just typing ^ and G, while ^G is actually a representation of a different ASCII character altogether. By using the command window method, you can save the actual keypress into the file. You can then edit the batch file if you want it to do other things, just make sure to preserve the line with the special character. It will probably just look like an empty box in notepad.

  • Sorry, that ^C is a typo. I did ctrl+G in the actual batch file. I'm pretty sure that's true because it does work when I run the file manually. Just to make sure, I redid the batch file properly just now, with the same results. I'm going to edit my question to avoid future confusion.
    – gorcq
    Apr 8 '11 at 4:26

Look for an option in your Task Scheduler in your Scheduled Task's properties called [something along the lines of] "interact with user" or "interactive" (or something like that). It should be a checkbox, and if you turn it on then it should cause your task to appear in the GUI as well as the audio system.

Failing that, Steve Gibson's (the creator of the famous SpinRite disk repair utility) has a freeware command-line tool called "Wizmo" which can play a .wav file from a batch file:

  Wizmo (no installation required - this is a stand-alone tool)

I'm hoping that this can do the job for you as well (if it does, then you'll obviously need to record a beep sound in a .wav file).

  • I don't see any options containing the word interactive or similar. I'm going to have to look more closely at that wizmo thing.
    – gorcq
    Apr 8 '11 at 3:44
  • @gorcq: I recall seeing this option in Windows XP, but in Windows 7 it does appear to have disappeared. That's too bad (I wish Microsoft wouldn't drop good features like this). =( Apr 8 '11 at 3:47
  • I saw the interactive option on Windows Server 2008 (Vista Server). Would they have removed it from 7 if Task Scheduler uses the same DLL for these two versions of Windows? EDIT I may be mistaken.
    – user3463
    Apr 8 '11 at 3:59
  • I have now tried with wizmo, and get the same problem: it works fine when run manually from the command line, but no beep when the Task Scheduler runs it. I just edited the batch file shown above and replaced all instances of "@echo ^C" with "wizmo play="C:\Windows\Media\Windows Critical Stop.wav"".
    – gorcq
    Apr 8 '11 at 4:06
  • 1
    @Randolph Potter: Thanks for confirming that I'm remembering rather than imagining! (I'm unable to edit my previous comment, so I just added this one with the correct spelling of Randolph's name.) Apr 12 '11 at 16:43

This code will save the character 0x07 (in hexadecimal == ^G == beep) in the variable and will be used by the echo command line.

Also invoking the rundll32.exe to output the sound contained in a .dll file, by/ @npocmaka in this answer.

@echo off && setlocal EnableDelayedExpansion

title <nul && title Windows Media Player && cd /d "%~dp0" 

%__APPDIR__%mode.com con: cols=50 lines=3 && cls && set "_url="
for /f %%i in ('%__APPDIR__%forfiles.exe /m "%~nx0" /c "cmd.exe /c echo/0x07"') do set "_Beep=%%~i"
echo/Starting Windows Media Player... & start "_"  "C:\Program Files (x86)\Windows Media Player\wmplayer.exe" %_url%

"%__APPDIR__%timeout.exe" /t 10 >nul & color f4
for /L %%L in (1 1 9)do echo/!_Beep!Times up^!!...&& %__APPDIR__%pathping.exe 127.1 -n -q 1 -p 666 >nul && (
     color 4f & %__APPDIR__%rundll32.exe %__APPDIR__%cmdext.dll,MessageBeepStub & color f4 & cls & echo/
     call "%__APPDIR__%pathping.exe" 127.1 -n -q 1 -p 666 >nul & echo/!_Beep!Times up^!!...& cls & echo/ 

"%__APPDIR__%taskkill.exe" /f /im "wmplayer.exe" >nul & endlocal & color 0a & goto :EOF

Not the answer you're looking for? Browse other questions tagged or ask your own question.