How to run audio from a batch file in the background? [closed]

Can it be done without any 3rd party software and if not, what should I use?


Solution 1:

You can create a vbscript to play an audio file. Create a new textfile and name it something like play.vbs

Your play.vbs file will look like this:

Dim oPlayer
Set oPlayer = CreateObject("WMPlayer.OCX")

' Play audio
oPlayer.URL = "C:\welcome.mp3"
oPlayer.controls.play 
While oPlayer.playState <> 1 ' 1 = Stopped
  WScript.Sleep 100
Wend

' Release the audio file
oPlayer.close

Solution 2:

NirCMD is a command line utility that can do a lot of things. You can use it to play audio files for a specified amount of time in milliseconds.

nircmd mediaplay 100000 "C:\Windows\Media\chimes.wav"