Batch file to change default audio device

MrDonkey

New member
Hi all,

I have my computer hooked up to a home theater system. Most of the time, my computer audio output is set to my on-board motherboard audio connected to simple speakers, but I frequently switch the default device to digital output through my sound card (HTO Striker 7.1).

My goal is to create a file that I can keep on the desktop that will switch the default audio device. In a perfect world, it would switch back and forth between the 2 settings that I use, but I understand that it might be too much to ask for.

I have a bit of experience with batch files in XP, but that was essentially reverse-engineering things that I found online. Any help would be appreciated. Thanks
 

My Computer

OS
Windows 7 64bit
Hi! Mr D, welcome to 7F :)

Would hotkeys fill the bill?

Source: AutoHotkey - Free Mouse and Keyboard Macro Program with Hotkeys and AutoText
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Gateway DX4831-01e (Mid-Tower Desktop)
OS
Originally Win 7 Hm Prem x64 Ver 6.1.7600 Build 7601-SP1 | Upgraded to Windows 10 December 14, 2019
CPU
Intel i3 530 2.93GHz, 2933MHz 2 Cores 4 Logical Processors
Motherboard
Gateway H57M01 133 megahertz
Memory
6GB of 1,333MHz DDR3 SDRAM
Graphics Card(s)
32MB Intel Graphics Media Accelerator HD IGChip
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Gateway HX2000 20inch TFT active matrix TN
Screen Resolution
1600 x 900 x 59 hertz
Hard Drives
WDC WD10EADS-00M2B0 [HDD] (1000.20 GB) -- drive 0,
HL-DT-ST DVDRAM GH41N [CD-ROM dr]
Four card readers, and Four USB 2.0
PSU
300watts.
Case
Mid-Tower Desktop
Cooling
Stock from Gateway
Keyboard
Natural Ergonomic Keyboard 4000, see Other Info
Mouse
Orig. Gateway wore out now using Insignia USB wired optical
Internet Speed
Vz FIOS 10ms png 57.64Mbps down 65.53Mbps up Speedtest.org
Antivirus
Zamana Anti-logger with Anti-malware, MSE, Windows Firewall,
Browser
IE11.0.9600.19399-Upd ver11.0.135, Firefox 68.0.1 x64
Other Info
System Specs by Belarc.

BIOS: American Megatrends Inc. P01-A0 11/17/2009

Replaced the MS 'Natural' Standard PS/2 Enhanced 101-102 Keyboard with a new Natural Ergonomic Keyboard 4000 on August 1st 2014.

Canon Pixma MG3222 Printer.

Updated to IE11 on 12102015 | Fios Quantum Router g1100

Additional AV: SpywareBlaster, manual Mbam, SAS
I'm hopefully looking for a solution that does not involve an additional program. I have a Logitech G11 keyboard, which has 18 customizable macro keys and its own macro program. I don't think there is a way within the Logitech program to change the default audio device, but I could be wrong, and I'll take a closer look
 

My Computer

OS
Windows 7 64bit
Understood if you have a keyboard that can do that, you would not want additional programs.

Take a look at this, It shows how to program the G-11 macros, and at the bottom it even describes how to include mouse clicks that would be very helpful during your programming of changing the sound devices.

Legacy Software - Programming macros on my G11 keyboard
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Gateway DX4831-01e (Mid-Tower Desktop)
OS
Originally Win 7 Hm Prem x64 Ver 6.1.7600 Build 7601-SP1 | Upgraded to Windows 10 December 14, 2019
CPU
Intel i3 530 2.93GHz, 2933MHz 2 Cores 4 Logical Processors
Motherboard
Gateway H57M01 133 megahertz
Memory
6GB of 1,333MHz DDR3 SDRAM
Graphics Card(s)
32MB Intel Graphics Media Accelerator HD IGChip
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Gateway HX2000 20inch TFT active matrix TN
Screen Resolution
1600 x 900 x 59 hertz
Hard Drives
WDC WD10EADS-00M2B0 [HDD] (1000.20 GB) -- drive 0,
HL-DT-ST DVDRAM GH41N [CD-ROM dr]
Four card readers, and Four USB 2.0
PSU
300watts.
Case
Mid-Tower Desktop
Cooling
Stock from Gateway
Keyboard
Natural Ergonomic Keyboard 4000, see Other Info
Mouse
Orig. Gateway wore out now using Insignia USB wired optical
Internet Speed
Vz FIOS 10ms png 57.64Mbps down 65.53Mbps up Speedtest.org
Antivirus
Zamana Anti-logger with Anti-malware, MSE, Windows Firewall,
Browser
IE11.0.9600.19399-Upd ver11.0.135, Firefox 68.0.1 x64
Other Info
System Specs by Belarc.

BIOS: American Megatrends Inc. P01-A0 11/17/2009

Replaced the MS 'Natural' Standard PS/2 Enhanced 101-102 Keyboard with a new Natural Ergonomic Keyboard 4000 on August 1st 2014.

Canon Pixma MG3222 Printer.

Updated to IE11 on 12102015 | Fios Quantum Router g1100

Additional AV: SpywareBlaster, manual Mbam, SAS
Thanks for the link. I think that once I have a file that can change the audio device, I can easily link to it through a macro. As far as I can tell, there is no way to access the terminal through the macro program, and even if there was, I need to figure out what commands to use.
 

My Computer

OS
Windows 7 64bit
Your welcome, but I do not understand your difficulty.

It would seem to me that once you start the macro program on the G-11 you would then preform the actions you do now to change from the on-board to the sound card whether or not it included a mixture of keys or clicks, then you save that macro as, lets say 'S_C' for Sound_Card to a key or key combo.

To change back to the on-board you start a fresh G-11 macro, preform the actions to do that, save that macro as 'O_B' to a key or key combo, and your done.

Not knowing the G-11 macro program it may even allow you to save the macro as a shorcut to your desktop, but I did not read that far.

Am I missing anything? That is how I used to make macros in Excel, and I had some doozys that would jump across several workbooks, files, and then to the printer.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Gateway DX4831-01e (Mid-Tower Desktop)
OS
Originally Win 7 Hm Prem x64 Ver 6.1.7600 Build 7601-SP1 | Upgraded to Windows 10 December 14, 2019
CPU
Intel i3 530 2.93GHz, 2933MHz 2 Cores 4 Logical Processors
Motherboard
Gateway H57M01 133 megahertz
Memory
6GB of 1,333MHz DDR3 SDRAM
Graphics Card(s)
32MB Intel Graphics Media Accelerator HD IGChip
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Gateway HX2000 20inch TFT active matrix TN
Screen Resolution
1600 x 900 x 59 hertz
Hard Drives
WDC WD10EADS-00M2B0 [HDD] (1000.20 GB) -- drive 0,
HL-DT-ST DVDRAM GH41N [CD-ROM dr]
Four card readers, and Four USB 2.0
PSU
300watts.
Case
Mid-Tower Desktop
Cooling
Stock from Gateway
Keyboard
Natural Ergonomic Keyboard 4000, see Other Info
Mouse
Orig. Gateway wore out now using Insignia USB wired optical
Internet Speed
Vz FIOS 10ms png 57.64Mbps down 65.53Mbps up Speedtest.org
Antivirus
Zamana Anti-logger with Anti-malware, MSE, Windows Firewall,
Browser
IE11.0.9600.19399-Upd ver11.0.135, Firefox 68.0.1 x64
Other Info
System Specs by Belarc.

BIOS: American Megatrends Inc. P01-A0 11/17/2009

Replaced the MS 'Natural' Standard PS/2 Enhanced 101-102 Keyboard with a new Natural Ergonomic Keyboard 4000 on August 1st 2014.

Canon Pixma MG3222 Printer.

Updated to IE11 on 12102015 | Fios Quantum Router g1100

Additional AV: SpywareBlaster, manual Mbam, SAS
The problem is that my current way of selecting the default audio device is to right-click on the sound icon, choose "playback devices", and then select the correct device. The macro program can record "mouse actions", which is restricted to the buttons and scroll, nothing about moving around the screen and doing something this complicated.

I've done what you are describing in Excel, but Visual Basic is a more powerful language, and never requires any mouse movement/actions.
 

My Computer

OS
Windows 7 64bit
That is just it, it does not need to track movement, it should just record your next click. What does it care how you get there it just needs to know your next choice.

What does it hurt to try?

I gotta go we are having a bad lighting storm and I am shutting down for the night.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Gateway DX4831-01e (Mid-Tower Desktop)
OS
Originally Win 7 Hm Prem x64 Ver 6.1.7600 Build 7601-SP1 | Upgraded to Windows 10 December 14, 2019
CPU
Intel i3 530 2.93GHz, 2933MHz 2 Cores 4 Logical Processors
Motherboard
Gateway H57M01 133 megahertz
Memory
6GB of 1,333MHz DDR3 SDRAM
Graphics Card(s)
32MB Intel Graphics Media Accelerator HD IGChip
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Gateway HX2000 20inch TFT active matrix TN
Screen Resolution
1600 x 900 x 59 hertz
Hard Drives
WDC WD10EADS-00M2B0 [HDD] (1000.20 GB) -- drive 0,
HL-DT-ST DVDRAM GH41N [CD-ROM dr]
Four card readers, and Four USB 2.0
PSU
300watts.
Case
Mid-Tower Desktop
Cooling
Stock from Gateway
Keyboard
Natural Ergonomic Keyboard 4000, see Other Info
Mouse
Orig. Gateway wore out now using Insignia USB wired optical
Internet Speed
Vz FIOS 10ms png 57.64Mbps down 65.53Mbps up Speedtest.org
Antivirus
Zamana Anti-logger with Anti-malware, MSE, Windows Firewall,
Browser
IE11.0.9600.19399-Upd ver11.0.135, Firefox 68.0.1 x64
Other Info
System Specs by Belarc.

BIOS: American Megatrends Inc. P01-A0 11/17/2009

Replaced the MS 'Natural' Standard PS/2 Enhanced 101-102 Keyboard with a new Natural Ergonomic Keyboard 4000 on August 1st 2014.

Canon Pixma MG3222 Printer.

Updated to IE11 on 12102015 | Fios Quantum Router g1100

Additional AV: SpywareBlaster, manual Mbam, SAS
The macro program can only track simple mouse commands. If I were to press record and then do what I normally do, the result would look like this:

Right-Click
Left-Click
Left-Click
Left-Click

I believe that I could create a macro that would go through the start menu, open audio devices, and then change the default using keystrokes, but that is not very efficient, and could be easily messed up by an accidental keystroke in the middle. I am really hoping for something like this:

1) Macro Button activates a specific batch file (I can do this part)
2) Batch file uses terminal commands to change the audio device (hopefully without extra windows being opened)

It seems to me that there should be a relatively simple command that changes the default audio device from the terminal, but I do not have enough experience to know what it is.
 

My Computer

OS
Windows 7 64bit
I just found this: Changing default audio deviceThey have some solutions that will quickly open the sound menu and select a different device. This is adequate, but if anyone knows a solution that does not rely on opening new windows, that would be preferable.
 

My Computer

OS
Windows 7 64bit
Have you seen this? NirCmd - Windows command line tool

In Ver 2.65 he added setdefaultsounddevice command (for Windows 7/Vista/2008 only), which allows you to set the default sound device.

You may get a warning when downloading some of Nir's programs, but I have never had any problems. Scan it before you open it.

There is another thread that I can ask for help with your situation, hopefully you can receive more help.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Gateway DX4831-01e (Mid-Tower Desktop)
OS
Originally Win 7 Hm Prem x64 Ver 6.1.7600 Build 7601-SP1 | Upgraded to Windows 10 December 14, 2019
CPU
Intel i3 530 2.93GHz, 2933MHz 2 Cores 4 Logical Processors
Motherboard
Gateway H57M01 133 megahertz
Memory
6GB of 1,333MHz DDR3 SDRAM
Graphics Card(s)
32MB Intel Graphics Media Accelerator HD IGChip
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Gateway HX2000 20inch TFT active matrix TN
Screen Resolution
1600 x 900 x 59 hertz
Hard Drives
WDC WD10EADS-00M2B0 [HDD] (1000.20 GB) -- drive 0,
HL-DT-ST DVDRAM GH41N [CD-ROM dr]
Four card readers, and Four USB 2.0
PSU
300watts.
Case
Mid-Tower Desktop
Cooling
Stock from Gateway
Keyboard
Natural Ergonomic Keyboard 4000, see Other Info
Mouse
Orig. Gateway wore out now using Insignia USB wired optical
Internet Speed
Vz FIOS 10ms png 57.64Mbps down 65.53Mbps up Speedtest.org
Antivirus
Zamana Anti-logger with Anti-malware, MSE, Windows Firewall,
Browser
IE11.0.9600.19399-Upd ver11.0.135, Firefox 68.0.1 x64
Other Info
System Specs by Belarc.

BIOS: American Megatrends Inc. P01-A0 11/17/2009

Replaced the MS 'Natural' Standard PS/2 Enhanced 101-102 Keyboard with a new Natural Ergonomic Keyboard 4000 on August 1st 2014.

Canon Pixma MG3222 Printer.

Updated to IE11 on 12102015 | Fios Quantum Router g1100

Additional AV: SpywareBlaster, manual Mbam, SAS

My Computer

Computer Manufacturer/Model Number
HP Pavilion dv9750
OS
Windows 7 Ultimate x64
CPU
Intel Core 2 T8300
Motherboard
Intel 945
Memory
4GB
Graphics Card(s)
nVidia 8600M
Sound Card
Onboard Realtek
Monitor(s) Displays
Laptop monitor 17"
Hard Drives
320GB & 500GB
PSU
External
Case
HP
Cooling
Fan Cooled
Back
Top