How can i play a sound (CPU Beep or wav, don't matter what) using the Windows cmd?
migrated from stackoverflow.com Jan 29 '10 at 2:01
|
Not in windows now, in order to test this possible solution, but try to: "start " I think it will open the wav file with the associated program that your windows has for ".wav" files. And note, this is a wild-guess - someone with windows may give you a better solution if this doesn't do the job |
|||||
|
|
You can do this natively with PowerShell. PowerShell is included with Windows Vista and later, and can be downloaded from Microsoft for older versions. Wave filesPowerShell can be used to load the
If you want, you can run this from the normal command line:
(note that And if you wanted to play only the first, say, 5 seconds of the sound:
BeepA beep can be easily accomplished in the normal command line with
Yes, it's the same as the An alternative method in PowerShell is to use the escape sequence for BEL, rather than inserting a literal BEL character with Ctrl + G:
To run this in a batch file (again, Vista or later):
|
|||
|
|
|
If a plain beep is alright, echo the character with the value 7, the so-called bell character. Note, however, that beeps can be turned off. If you want something else, you'll have to launch an application that does the trick. |
|||
|
|
|
You could write a simple console application that took the sound file (or sound id) as an argument and called PlaySound |
|||
|
|
|
Download this , save it somewhere. In a cmd window run:
The file holds just a single character - the BEL character . Ascii value 7. |
|||
|
|
|
On XP I do this
It's not ideal but it's really easy and it works. |
|||
|
|
|
Install VLC. Use the following command. It starts up REALLY fast. This is what I used on Windows 7 b/c wmplayer takes so long to load, and the /close option was removed.
|
|||
|
|
|
I use
You should add mplayer.exe to your PATH (see What are PATH and other environment variables, and how can I set or use them? or How can I permanently append an entry into the system's PATH variable, via command line? to do this.) |
|||
|
|
start file.wavis a bad idea. It might take a second to start a bloated media player, just for a single beep. In addition, file associations might be wrong, the media player might not play the file, or it might play it over and over again, etc. The way of creating a simple "beep" is to writebeep ^G. "^G" is not the circumflex accent followed by a capital letter G, but rather a special character that you insert by pressing Ctrl+G. It is actually the BEL character with ASCII value 0x07. – Andreas Rejbrand Aug 25 '10 at 20:30