Disabling the webcam programmatically under Windows
See the question and my original answer on StackOverflowHere are two links here on SO to enable/disable a device programmatically:
How do I disable a system device?
Win32 API function to programmatically enable/disable device
There is also an official tool, DevCon, that you could automate.
DevCon (Devcon.exe), the Device Console, is a command-line tool that displays detailed information about devices on computers running Windows. You can use DevCon to enable, disable, install, configure, and remove devices.