Search code examples
windowswebcam

How to enable/disable webcam by script (Win 10)


I'm using for win 10 on my laptop and sometimes I need ti enable/disable my build in webcam and mic by any script or .exe file. In other words I need to switch this one by script: WebCam Settings I tried to find something in Google, but without success. Tell me where to start?


Solution

  • You can disable and enable your webcam using PowerShell script.

    1. List all your cameras:

      Get-PnpDevice -FriendlyName *webcam* 
      
    2. Filter camera by status:

      Get-PnpDevice -FriendlyName *webcam*  -Status OK
      
    3. Disable the camera:

      Disable-PnpDevice -InstanceId (Get-PnpDevice -FriendlyName *webcam*  -Status OK).InstanceId    
      
    4. Enable the camera:

      Enable-PnpDevice -InstanceId (Get-PnpDevice -FriendlyName *webcam*  -Status Error).InstanceId
      

    enter image description here