how to disable / enable devices using command line in Windows 10


  1. Posts : 19
    Windows 10 21H1 OS Build 19043
       #1

    how to disable / enable devices using command line in Windows 10


    Hello friends,

    Prior to updating to 1803 my headphones/laptop speakers were working just fine. When I connect my USB headphones, audio automatically redirected to headphones but not any more (after updating to 1803). Now, I need to manually disable speakers after connecting headphones (vice versa for speakers) to make them work.

    I'm more of a typing guy (text/command line etc.) than GUI so I would like to know how could I enable/device through command line. I tried DevCon tool ( DevCon Status | Microsoft Docs ) but when I run it says successful but it does NOT actually disable the device. Of course, I used "Elevated command prompt (admin)"

    Any advise on how to disable/enable devices in Windows 10 command-line please? Thanks!!

    how to disable / enable devices using command line in Windows 10-image.png
      My Computer


  2. Posts : 5,478
    2004
       #2

    You could try nircmd if you don't mind third party - Nirsoft utilities are quite trustworthy.

    There is a good tutorial here : Creating a shortcut to change the default audio device in Windows
      My Computer


  3. Posts : 19
    Windows 10 21H1 OS Build 19043
    Thread Starter
       #3

    Thanks lx07 for your reply, I don't mind using 3rd party tools but unfortunately that's NOT what I need. Even using GUI, setting default audio device does not work (as I mentioned in my first post). Only IF I disable speakers then my USB headphone is working (after 1803 update), setting default audio device is not enough.

    Again, basically I need a cmd line tool that can disable an audio device (not setting default) however I tried nircmd with setdefault but doesn't do what I need. I also tried to see if I can use nircmd to disable an audio device but it doesn't seem to offer that one.

    regards,
      My Computer


  4. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    Before using the suggestions below, I would urge you to check for updated drivers for your speakers / headphones because the problem you are experiencing might simply be that the currently installed drivers are not fully compatible with the latest Windows 10 updates.

    If you look at Enable or Disable Microphone - TenForums you will see the basic procedure you need to follow but, since you are talking about speakers & headphones you need to look a few lines down in the Registry to Render instead of Capture. The layout of the Capture & Render Registry keys is the same so I think there is every chance that you will be able to do what you want.

    You will probably have to experiment. I have done so a bit and I think that DeviceState 8 probably means not connected / not available. I only have my internal speakers and my Bluetooth earphones to use for comparative tests so there might be more to it than meets the eye.

    I do suggest at the every least exporting the Registry key[s] you are going to work on beforehand so you can get back to where you started if it goes wrong.
    - Export the Registry key[s] in .reg format not .txt format. You can then run the .reg file afterwards if necessary to return the key[s] to their former values.
    - Personally, I would make a system image beforehand to make sure I would be able to escape from any problems.
    - I always make system images before making any significant changes and, in this case, you will not be following a previously tested procedure [for headphones] so it is doubly important.

    If you set this up manually at first to make sure it does work then you will be able to automate it all later using the Reg command [which is not the same as RegEdit]. I think you will want to use a pair of batch files that might need to run elevated [Admin] to set it up one way or the other [toggling as you change what you connect] using commands in the form
    REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
    You can get info by opening an elevated command window and entering
    Reg Add /?
    or something like this to save a copy in a text file [in a folder that exists on your computer instead of my own D:\Desktop]
    Reg Add /? >D:\Desktop\RegAddSyntax.txt

    There are examples of using Reg Add in this forum such as in "REG DELETE" from CMD prompt. Ran into a problem where you will see competent advice by @TairikuOkami and probably by other contributors.

    Best of luck,
    Denis
    Last edited by Try3; 25 May 2018 at 22:20.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:34.
Find Us




Windows 10 Forums