Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device Enable/Disable script

I have Windows 7 64 Bit Professional Edition on a computer I built myself so there is no manufacturer to ask. I am using an on-board sound card which has 7.1 and Optical outputs. The optical output is plugged into a Denon amp which controls the speakers.

I have got a speaker system plugged into my computer through the optical port on my sound card. When I use standard windows drivers I only get stereo output so I installed the Realtek HD audio driver. This gives me surround sound successfully however it does not tie this as a standard speaker so when I plug in headphones and define them as headphones nothing happens the audio still goes to the speaker system and nothing to the headphones.

I have discovered that if I disable the Digital output device in the playback devices list the audio is automatically rerouted through the headphones. Therefore I have been trying to find a way of disabling or enabling this device. I have a programmable keyboard so I can map a program or script to a spare key therefore I am trying to write a program to check if the device is enabled or disabled then change this to whatever it is not i.e. if on turn off and if off turn on.

I attempted to locate the hardware IDs which are
1. "HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601"
2. "HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601&REV_1000"

I had planned to create a batch script using devcon (the command line alternative to device manager.) using the below code to disable or enable the device

devcon disable "HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601*"
devcon enable "HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601*"

However devcon fails to disable these devices as the optical connection is on the sound card and I can only disable the entire sound card which would also disable the headphones.

I am a little lost as to what to do now and I really don't want my brother to need to play with disabling devices.

I am open to any suggestions. I am happy to use any language to do this. Im sure there must be a way of doing this from c but I have been unable to locate any information on this. I would appreciate any suggestions. I am quite happy to write the program myself but if someone could at least point me in the right direction to an api or something like devcon or some way in some language to do this. I currently know VB6, VB.NET, VB Script, Java and Batch Scripting and Powershell quite well and have some knowledge of C, C++ and C#.NET.

any and all help would be appreciated

Kind Regards
Dexter

like image 264
feldoh Avatar asked Nov 05 '22 06:11

feldoh


1 Answers

You can try with this :

devcon /r disable @"HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601*"
devcon /r enable @"HDAUDIO\FUNC_01&VEN_10EC&DEV_0888&SUBSYS_105BA601*"

Regards,

Pal

like image 121
Pal Avatar answered Nov 09 '22 06:11

Pal