Search code examples
windowsbatch-filewindows-7mp3silent

Batch file executing a sound silently


Would it be possible to execute a mp3 silently from batch I have tried:

@echo off
1.mp3
pause

It works but it doest do it silently it launches WMP. does any one know how I could accomplish this. I am making a program and the track it one of the sound effects.


Solution

  • Here is a Bat/VBS to play an audio file :

    @echo off
    set file=track12.mp3
    ( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
      echo Sound.URL = "%file%"
      echo Sound.Controls.play
      echo do while Sound.currentmedia.duration = 0
      echo wscript.sleep 100
      echo loop
      echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
    start /min sound.vbs
    

    Or you can use this small command i wrote in Autoit (playsound.exe)

    Use : playsound.exe "youraudiofile.mp3/wav"