How to Enable/Disable audio devices

Ramashankar Agrahari (India) 25 Reputation points
2024-03-14T09:13:27.3433333+00:00

Hi,

I want to enable/disable audio devices listed in sound control panel (mmsys.cpl) but either through programmatically or through any power shell commands/scripts or windows internal utilities(pnputil, devcon).

I tried using WMI APIs, Core Audio APIs, pnputil, devcon utilities. But with any of these I am either able to enable/disable an audio endpoint from (AudioEndpoint class) or a media device (Media class). None of these provide similar behavior what we get when disabling audio device through right clicking on it in sound control panel.

Observations:

  1. If I use device id of an AudioEndpoint to disable, it gets disabled only in device manager under 'Audio inputs and outputs' section, but not in sound control panel or any other application which are using it.
  2. If I use device id of a Media to disable, it gets disabled in device manager under 'Sound, video and game controllers' section, but removes the devices completely from sound control panel.
  3. If I disable the device from sound control panel by right clicking on it, it gets disabled and unavailable for all apps immediately. It also gets removed from 'Audio inputs and outputs' section in device manager but no impact in 'Sound, video and game controllers' section.

I want to achieve this observation (3) through program or commands.

Please suggest how to do it.

Thanks.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,515 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,405 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,341 Reputation points
    2024-03-19T12:13:31.0166667+00:00

    If you want to disable a sound device like in the Sound Control Panel, it is done with IPolicyConfig and SetEndpointVisibility

    2 people found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Castorix31 81,341 Reputation points
    2024-03-14T11:51:56.4466667+00:00
    1 person found this answer helpful.

  2. Ramashankar Agrahari (India) 25 Reputation points
    2024-04-09T09:59:06.61+00:00

    Accepted answer:

    Castorix31 • Mar 19, 2024, 5:43 PM

    If you want to disable a sound device like in the Sound Control Panel, it is done with IPolicyConfig and SetEndpointVisibility