Search code examples
vbscriptmp3

Playing a sound file (MP3) with vbscript


Is there a way to play a sound file (MP3), with visual basic script?

Set obj = CreateObject("WScript.Shell")
obj.run "C:/test.mp3" 

There are some other ways that if tried as well but they didnt work.

One didnt display sound but had no errors whenthe script ran.


Solution

  • With CreateObject("WMPlayer.OCX")
        .url = "C:\Test\test.mp3"
        .controls.play
        Do
                WScript.Sleep 100
        Loop Until .playState = 1
    End With