Important: This documentation has not quite caught up with the new release (SetDefaultAudioEndpoint-2011-03-15).

Overview

SetDefaultAudioEndpoint can change the default audio endpoint on a Windows system. An audio endpoint is an audio device attached to the system. Audio devices are used for both playback and recording. SetDefaultAudioEndpoint can change the default playback device and the default recording device.

Use

To change the default playback device, from a command prompt or with a scripting language, enter
SetDefaultAudioEndpoint.exe -p"Playback Device Name"
where Playback Device Name is the name of an audio device on the Playback tab of the Sound control panel.

To change the default recording device, from a command prompt or with a scripting language, enter
SetDefaultAudioEndpoint.exe -r"Recording Device Name"
where Recording Device Name is the name of an audio device on the Recording tab of the Sound control panel.

To access the Sound control panel, search for "Manage audio devices" from the Windows 7 start orb.

Operation

SetDefaultAudioEndpoint uses the Windows 7 Sound control panel window to make changes. The Sound control panel window is used because Microsoft has not officially sanctioned any other programmatic means to make this change.

If the Sound control panel window is open when SetDefaultAudioEndpoint executes, the window will remain open after execution completes. Otherwise, the window will be closed.

If the operation completes successfully, text similar to the following is returned to the console: "The default audio playback device was set to 'Speakers'."

Invalid Operation

SetDefaultAudioEndpoint will return an error under any of the following circumstances:
  • The audio device name cannot be found. In this case, a list of audio devices is returned to the console.
  • The audio device cannot be set as the default audio endpoint. This can happen if the device is already the default audio endpoint.
  • The Sound control panel window could not be opened. This can happen if there is other activity on your system when SetDefaultAudioEndpoint is executing. Increase the value TryFindSoundWindowTimeoutMilliseconds in the file bin\SetDefaultAudioEndpoint.exe.config if this problem persists. (The default value is 5001 milliseconds, or 5 seconds.)

Text describing the error is returned to the console.

Last edited Mar 16, 2011 at 5:49 AM by leqid, version 6

Comments

coding_idiot Dec 2, 2013 at 10:02 PM 
It works perfectly fine, if the devices are enabled. I disabled a device & tried it, & it didn't worked. Gave the error - device with "..." name not found. Although after enabling the device, the command works perfect. Is there a solution to to first enable disabled devices & then set them default ?