Reputation: 75
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?
Upvotes: 7
Views: 16977
Reputation: 361
Mmmmh... it works if you are not using the webcam, but if it is still active it shows this error (running the powershell script as administrator):
Disable-PnpDevice : Generic failure
At line:1 char:1
- Disable-PnpDevice -InstanceId (Get-PnpDevice -FriendlyName "USB Video ...
+ CategoryInfo : NotSpecified:
(Win32_PnPEntity...7&169FD4E3&...):ROOT\cimv2\Win32_PnPEntity) [Disable-PnpDevice], > CimException
- FullyQualifiedErrorId : HRESULT 0x80041001,Disable-PnpDevice
Upvotes: 0
Reputation: 12140
You can disable and enable your webcam using PowerShell script.
List all your cameras:
Get-PnpDevice -FriendlyName *webcam*
Filter camera by status:
Get-PnpDevice -FriendlyName *webcam* -Status OK
Disable the camera:
Disable-PnpDevice -InstanceId (Get-PnpDevice -FriendlyName *webcam* -Status OK).InstanceId
Enable the camera:
Enable-PnpDevice -InstanceId (Get-PnpDevice -FriendlyName *webcam* -Status Error).InstanceId
Upvotes: 11