title: Device Enable/Disable script
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>I attempted to locate the hardware IDs which are<br/>1. "HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_105BA601"<br/>2. "HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_105BA601&amp;REV_1000"</p>
  
  <p>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 
  <p><code>
  devcon disable "HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_105BA601*"<br/>devcon enable "HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_105BA601*"
  </code></p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>any and all help would be appreciated</p>
  
  <p>Kind Regards<br/>Dexter</p>