<http://www.netikka.net/tsneti/info/tscmd092.htm>
Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Mon 24-May-2010 20:01:16

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



92} How do I play a sound or a tune from the command line?

The simplest way to emit a brief beep is
  @echo <Ctrl-G>

How to enter the ASCII 7 character depends on your editor program. One fairly common way of entering the beep character is entering 007 from the numeric keypad while holding down the ALT key. Or you could even put the character as follows in a file and copypaste it from there.
  gawk 'BEGIN{printf "%%s","\x07"}'>beepchar.txt
or
  gawk 'BEGIN{printf "@rem %%s\n","\x07"}'>>myfile.cmd

If you can get hold of QBASIC it has a PLAY statement. For example
  @echo off & setlocal enableextensions
  set bas_=%temp%\tmp$$$.bas
  for /f "tokens=*" %%f in ("%bas_%") do set bas_=%%~sf
  > %bas_% echo PLAY "l8 o3 cdefgab o4 cd"
  >>%bas_% echo SYSTEM
  qbasic /run %bas_%
  for %%f in (%bas_%) do if exist %%f del %%f
  endlocal & goto :EOF

The Sound Recorder can be used to play a Wave Audio Sound file (.WAV). For example
  sndrec32.exe /play /close %SYSTEMROOT%\Media\tada.wav
or, without displaying the Sound Recorder window on the desktop
  start /min "" sndrec32 /play /close %SYSTEMROOT%\Media\tada.wav

References/Comments: (If a Google message link fails try the links within the brackets.)
  How to Play a Sound File
  Google Groups Jan 7 2005, 7:07 pm [M]
  Google Groups Apr 23 2005, 5:55 pm [M]
  Google Groups Jun 11 2008, 6:16 pm [M]