Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created December 25, 2015 09:21
Show Gist options
  • Save nasitra/ccf751825ce83e7613e6 to your computer and use it in GitHub Desktop.
Save nasitra/ccf751825ce83e7613e6 to your computer and use it in GitHub Desktop.
Play a sound file in Windows Media Player
Set objParm = Wscript.Arguments
If objParm.Count < 1 Then
WScript.Echo "play.vbs [path]"
WScript.Quit
End If
Set wmp = WScript.CreateObject("WMPlayer.OCX")
Sub waitWMPlayerStop()
Do
WScript.sleep(100)
Loop Until wmp.playState = 1
End Sub
Sub play(path)
wmp.URL = path
wmp.Controls.currentPosition = 0
wmp.Controls.play()
waitWMPlayerStop
End Sub
wmp.settings.volume = 100
play objParm(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment