A PowerShell script with a CMD wrapper to easily switch between audio devices on Windows, utilizing nircmd.exe
. Perfect for use with keyboard macro keys, or devices like a Stream Deck.
- Quickly toggle between two audio devices.
- Includes a CMD wrapper for seamless integration with macro systems or hotkey setups.
- Uses
nircmd.exe
for reliable audio device switching. - Customizable to match your setup.
- Windows operating system.
- PowerShell 5.1 or later.
nircmd.exe
(provided in the repository).- Renamed audio devices in Windows to match the script variables.
- Clone the repository or download the files directly:
git clone https://github.com/r0r0sec/AudioDeviceChanger.git
- Navigate to the directory where the files are located:
cd AudioDeviceChanger
For the script to work, your audio device names in Windows must match the values set in the script. To rename your audio devices:
- Go to Settings → System → Sound → Output.
- Click on your desired audio device and rename it, for example:
Headphones
Speakers
- Update the script variables values in
AudioDeviceChanger.ps1
if you use different names:# Update these values in the script $AudioDevice_1 = "YourDevice1Name" $AudioDevice_2 = "YourDevice2Name"
- Open PowerShell in the script's directory.
- Run the script or right-click "Run with PowerShell":
.\AudioDeviceChanger.ps1
- The script will toggle between the two configured audio devices.
- Open a CMD interface in the script's directory.
- Run the script or just double-click the file:
PSWrapper.cmd
- The script will toggle between the two configured audio devices.
The PSWrapper.cmd
file allows you to execute the script silently in the background, ideal for hotkeys or integration with devices like a Stream Deck.
In order to have the script run in the background, you can use the provided nircmd.exe
and integrate it with the following command:
- Right-click the Stream Deck system tray icon "Configure Stream Deck"
- Add a new key from the Navigation "System" -> "Open"
- Paste the following command under "App / File:"
"..\AudioDeviceChanger\nircmd-x64\nircmd.exe" exec hide "..\AudioDeviceChanger\PSWrapper.cmd"
This will execute the script without bringing up any visible windows, ensuring a seamless user experience.
Contributions are welcome! Please submit a pull request or open an issue if you have ideas for improvements or encounter any bugs.
This project uses NirCmd, a freeware utility developed by NirSoft. NirCmd is licensed as freeware and can be freely distributed as long as no modifications are made to the original files.
For more information and to download the utility, visit: https://www.nirsoft.net/utils/nircmd.html.
Note: The NirCmd files included in this project have not been modified in any way.
- Thanks to NirSoft for the fantastic
nircmd.exe
utility.