Here is the one-line code to enable or disable the web cam when you want. Here is how it works.
I wrote a one line code and save it as a PowerShell (.ps1) file. Created a batch file to call the PowerShell script files to enable or disable the web cam.
Prerequisite
Open PowerShell and type (or copy/paste). This will display all of your Camera device(s).
Get-PnpDevice | ? {$PSItem.Class -eq 'Camera'} | fl FriendlyName,InstanceId
Here is the example: E:> Get-PnpDevice | ? {$PSItem.Class -eq 'Camera'} | fl FriendlyName,InstanceId FriendlyName : Integrated Camera InstanceId : USB\VID_04CA&PID_703C&MI_00\7&36726615&0&0000 FriendlyName : S-YUE 8MP USB Camera InstanceId : USB\VID_0BDA&PID_5075&MI_00\8&3E5D74C&0&0000
Now note down the Instance ID of the current camera (copy it to the clipboard).
Creating the PowerShell and Batch files
Disable Script
- PowerShell script file
Type the command below in a Notepad/Editor and replace the InstanceID you noted down above.
Disable-PnpDevice -InstanceId 'USB\VID_0BDA&PID_5075&MI_00\8&3E5D74C&0&0000' -Confirm:$false
Save the file as Disable-Camera.ps1.
2. Batch file
Type the command below in a Notepad/Editor and replace the path of your Powershell Scirpt file. Save the file as Disable-Camera.bat
PowerShell.exe -Command "C:\Temp\Disable-Camera.ps1"
Enable Script
- PowerShell script file
Type the command below in a Notepad/Editor and replace the InstanceID you noted down above.
Enable-PnpDevice -InstanceId 'USB\VID_0BDA&PID_5075&MI_00\8&3E5D74C&0&0000' -Confirm:$false
Save the file as Enable-Camera.ps1.
2. Batch file
Type the command below in a Notepad/Editor and replace the path of your Powershell Scirpt file. Save the file as Enable-Camera.bat
PowerShell.exe -Command "C:\Temp\Enable-Camera.ps1"
How to use it?
Here are my created files:

I made the shortcut for the Batch file on my desktop. When I needed, I right-click on the shortcut icons, select Run as Administrator.
To enable or disable the device, script has to run in elevated PowerShell. That’s why you have to run the shortcut Run as Administrator.

Better yet, I use Circle Dock to quickly launch programs. So I created two new icons for it.

Good stuff Anand.