1

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.

Community
  • 1
  • 1
  • I think you have to escape the `(` as well. Also take a look at the `.vbs` you're generating to check if it's correct. – dcg Apr 04 '17 at 22:41
  • @dcg Well the script does work and it does play the sound file I give to it, but I would like to know if it's possible to output the audio to a different audio device – MichielP1807 Apr 04 '17 at 22:45
  • 1
    Possible duplicate of [Switching current active sound device using VBScript?](http://stackoverflow.com/questions/21800476/switching-current-active-sound-device-using-vbscript) –  Apr 04 '17 at 22:51
  • 1
    @MattPerry I'm not trying to switch my default audio devices, I'm trying to output the sound file that the script is playing to different audio devices which is in my case a virtual audio cable – MichielP1807 Apr 04 '17 at 22:55

0 Answers0