An audio device switcher written in Batch and Cscript using SoundVolumeView.
Description: a collection of scripts that can set the default audio device, check what is the current default audio device, or switch between 2 devices.
- SoundVolumeCommandLine v1.25 by Nir Sofer - Website.
The scripts could work with different versions, but that is the ones that was tested.
- Download and unpack the dependency.
- Download the desired scripts and
variables.csv
. The scripts are intentionally separate from each other, so you can download only the ones that you're going to use.
Tip
Place the files in the same folder as svcl.exe
for ease of use.
- Update
variables.csv
file so it fits your needs:
SoundVolumeView,<relative path to svcl.exe>
TIMEOUT,<how many seconds information popups wait before automatically closing>
COLUMN,<name of the column in SoundVolumeView that indicates your default device>
DEFAULT,<keyword that appears in COLUMN for your default device>
S_DEVICE,<name of 1st audio device>
H_DEVICE,<name of 2nd audio device>
S_VOLUME,<default volume for 1st device>
H_VOLUME,<default volume for 2nd device>
Note
Notice that the variables are currently set to switch between a Headset and Speakers, so the comments in the code and file names reflect that, but you could use these scripts to switch between any 2 devices.
Checks which audio device (out of 2 options) is currently set as default and displays the information in a popup. If the current default device isn't one of the options an error message will be displayed.
- SoundVolumeView, TIMEOUT, COLUMN, DEFAULT, H_DEVICE, S_DEVICE
- Reads variables from
VARS_PATH
(relative path tovariables.csv
, declared inside the script) - Uses
SoundVolumeView
to get the value ofCOLUMN
forS_DEVICE
andH_DEVICE
. - Finds which device's state is set to the
DEFAULT
keyword. - Displays info popup for
TIMEOUT
seconds.
Checks which audio device (out of 2 options) is currently set as default, sets the other device to default and displays the information in a popup. If the current default device isn't one of the options an error message will be displayed.
- SoundVolumeView, TIMEOUT, COLUMN, DEFAULT, H_DEVICE, S_DEVICE, H_VOLUME, S_VOLUME
- Reads variables from
VARS_PATH
(relative path tovariables.csv
, declared inside the script) - Uses
SoundVolumeView
to get the value ofCOLUMN
forS_DEVICE
andH_DEVICE
. - Finds which device's state is set to the
DEFAULT
keyword. - Uses
SoundVolumeView
to switch default device to the other device. - Uses
SoundVolumeView
to set default volume to the other device's default volume. - Displays info popup for
TIMEOUT
seconds.
Checks which audio device (out of 2 options) is currently set as default, displays the information in a popup and asks user if should switch devices. If user selects "ok" in the prompt, sets the other device to default and displays the information in a popup. If the current default device isn't one of the options an error message will be displayed.
- SoundVolumeView, TIMEOUT, COLUMN, DEFAULT, H_DEVICE, S_DEVICE, H_VOLUME, S_VOLUME
- Reads variables from
VARS_PATH
(relative path tovariables.csv
, declared inside the script) - Uses
SoundVolumeView
to get the value ofCOLUMN
forS_DEVICE
andH_DEVICE
. - Finds which device's state is set to the
DEFAULT
keyword. - Displays prompt popup.
- If selected "ok":
- Uses
SoundVolumeView
to switch default device to the other device. - Uses
SoundVolumeView
to set default volume to the other device's default volume. - Displays info popup for
TIMEOUT
seconds.
- Uses
- If selected "cancel":
- Exits.
Sets H_DEVICE
audio device to default regardless of the current default device and displays the information in a popup.
- SoundVolumeView, TIMEOUT, H_DEVICE, H_VOLUME
- Reads variables from
VARS_PATH
(relative path tovariables.csv
, declared inside the script) - Uses
SoundVolumeView
to switch default device toH_DEVICE
. - Uses
SoundVolumeView
to set default volume toH_VOLUME
. - Displays info popup for
TIMEOUT
seconds.
Sets S_DEVICE
audio device to default regardless of the current default device and displays the information in a popup.
- SoundVolumeView, TIMEOUT, S_DEVICE, S_VOLUME
- Reads variables from
VARS_PATH
(relative path tovariables.csv
, declared inside the script) - Uses
SoundVolumeView
to switch default device toS_DEVICE
. - Uses
SoundVolumeView
to set default volume toS_VOLUME
. - Displays info popup for
TIMEOUT
seconds.
- Run the desired script to switch/check your default audio device .
Tip
Create a shortcut to a script on your desktop, open its properties and change Run
to Minimized
, that'll enable it to run in the background and only display the end result. Run the script via the shortcut instead of running the file directly.
Tip
If your keyboard or mouse has programmable buttons you can set some to run your shortcut(s) to switch/check audio device without needing to go to your desktop.