If you want to disable a sound device like in the Sound Control Panel, it is done with IPolicyConfig and SetEndpointVisibility
How to Enable/Disable audio devices
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:
- 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.
- 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.
- 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.
2 additional answers
Sort by: Most helpful
-
Castorix31 88,376 Reputation points
2024-03-14T11:51:56.4466667+00:00 -
Ramashankar 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