Play invisible music with batch file?
CreateObject("Wscript.Shell").Run "wmplayer /play /close ""Your file location here""", 0, False
Obviously very late for the asker of the question but who knows? Someone else may look by. So I'll just reiterate Tony BD's answer from April '14, and since someone complained about it being a code only answer I'll add a little explanation and really very little is required.
1.) Open Windows Notepad
2.) Copy Tony BD's code into Notepad
3.) Substitute 'Your file location here' with the full path to the music file you want to play.
4.) In Notepad menu choose File|Save as . .
5.) Choose a location and give the file a name but ensure that instead of the standard .txt file type you give it a .vbs ending.
6.) Close Notepad
7.) Click on the vbs file you just made and your music file will start to play showing absolutely nothing on the screen.
The 0 parameter in the code enables WMP to open in an invisible window. If you change the 0 to a 1 you will see WMP's graphical interface.
Obviously this is only available for Windows users but for them it's the best and simplest solution to the problem.
@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
just change track12.mp3
with the name of your audio file
To loop the same song:
@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
:loop
start "" /wait /min sound.vbs
goto:loop