Skip to content

Instantly share code, notes, and snippets.

@jmac-slash0
Created November 3, 2017 19:07
Show Gist options
  • Save jmac-slash0/73196eb3ccb0cb507cb1a372d9a3bd8b to your computer and use it in GitHub Desktop.
Save jmac-slash0/73196eb3ccb0cb507cb1a372d9a3bd8b to your computer and use it in GitHub Desktop.
Call nircmd to change the current audio device
Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("..\nircmd.exe setdefaultsounddevice ""Speakers"" 1", 0, True) ' Default Device
cmds=WshShell.RUN("..\nircmd.exe setdefaultsounddevice ""Speakers"" 2", 0, True) ' Default Communications Device
Set WshShell = Nothing
@jmac-slash0
Copy link
Author

Install:

  • Download NirCmd: http://www.nirsoft.net/utils/nircmd.html
  • Extract zip to desired location and create a new folder inside called "scripts"
  • Place activateSpeakers.vbs in the newly created scripts folder
  • Edit the script so the "Speakers" name matches your desired audio device name exactly

Usage:
Run activateSpeakers.vbs by double clicking on it, or by creating a shortcut that points to it and running that. For example, I have 2 copies of this script, one for my speakers and one for my headphones, with shortcuts for both.

Additional Reading:
http://www.microsoftnow.com/2013/05/creating-a-shortcut-to-change-the-default-audio-device-in-windows.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment