Skip to content

Instantly share code, notes, and snippets.

@anteriovieira
Last active January 13, 2017 18:21
Show Gist options
  • Save anteriovieira/15189ac5892297868af7139c10d8dfb2 to your computer and use it in GitHub Desktop.
Save anteriovieira/15189ac5892297868af7139c10d8dfb2 to your computer and use it in GitHub Desktop.
@echo off
REM Script to play a song
REM Example:
REM to-play.cmd url_to_file|path_to_file
REM Set file name
set file=%1
REM Create temp file
(
echo Set player = CreateObject("WMPlayer.OCX.7"^)
echo player.URL = "%file%"
echo player.Controls.play
echo do while player.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(player.currentmedia.duration^)+1^)*1000
) > %USERPROFILE%\player.vbs
REM Start player with song
echo Playing song... && "%USERPROFILE%\player.vbs" ^&^& exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment