I'm trying to make a script that plays audio to a specific audio device, because I want to use a virtual audio cable to manage where the audio is going (broadcasting software, discord etc.). I've got a batch script that creates a vbscript that will play the sound. This is the code in the batch script:
@echo off
set "file=%1"
( 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
The reason I've got this batch script is so I can do something like PlaySound.bat airhorn.wav
to play an audio file.
Is there a possible way to play the sound to a specific audio channel?
EDIT: Just to clarify, the script does work and it does play the sound file correctly, but I would like to output the file to a different non-default audio devices which is in my case a virtual audio cable. I don't want to toggle the default audio device I just want to play sound and output that sound to a different non-default audio device.
EDIT 2: I've gone with a different solution, which you can see here.