16

I have multiple laptops I can remote into, but I do not know whether they have a working webcam. I cannot see them. I do not need to access the webcams; I just need to know if one is present.

Is there a way to remotely tell whether a laptop has a webcam?

I would prefer some sort of cmd code that I can trigger on each to quickly give me a copy-able printout of such information to compile across computers.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
theforestecologist
  • 586
  • 1
  • 9
  • 26

3 Answers3

30

On Windows, you can look in Device Manager to check whether camera devices exist. This check can also be performed using PowerShell or Command Prompt, without special rights.

Command Prompt:

pnputil /enum-devices /class Camera /connected

Will print:

Microsoft PnP Utility

Instance ID:                USB\VID_0C45&PID_672E&MI_02\6&3d846a0&0&0002
Device Description:         Integrated Webcam
Class Name:                 Camera
Class GUID:                 {ca3e7ab9-b4c3-4ae6-8251-579ef933890f}
Manufacturer Name:          Microsoft
Status:                     Started
Driver Name:                usbvideo.inf

Instance ID:                USB\VID_0C45&PID_672E&MI_00\6&3d846a0&0&0000
Device Description:         Integrated Webcam
Class Name:                 Camera
Class GUID:                 {ca3e7ab9-b4c3-4ae6-8251-579ef933890f}
Manufacturer Name:          Microsoft
Status:                     Started
Driver Name:                usbvideo.inf

Instance ID:                USB\VID_0FD9&PID_0078&MI_00\8&e3fc9d&0&0000
Device Description:         Elgato Facecam
Class Name:                 Camera
Class GUID:                 {ca3e7ab9-b4c3-4ae6-8251-579ef933890f}
Manufacturer Name:          Microsoft
Status:                     Started
Driver Name:                usbvideo.inf

PowerShell:

Get-PnpDevice -PresentOnly -Class Camera

Will print:


Status     Class           FriendlyName                                                                     InstanceId
------     -----           ------------                                                                     ----------
OK         Camera          Integrated Webcam                                                                USB\VID_0C45...
OK         Camera          Integrated Webcam                                                                USB\VID_0C45...
OK         Camera          Elgato Facecam                                                                   USB\VID_0FD9...

You cannot reliably distinguish internal and external cameras using trivial filters (as shown above). You’ll have to go by the name or other hints.


Some older webcams which do not use the USB Video Class may not appear in the Camera class. Instead, the could be using the Image class, which today is usually used for document scanners and the like.

With pnputil, you’ll have to run two commands to get both classes. With PowerShell, you only need one:

Get-PnpDevice -PresentOnly -Class Camera,Image

Output (different PC, without -PresentOnly, hence the Unknown):

Status     Class           FriendlyName                                                                     InstanceId
------     -----           ------------                                                                     ----------
Unknown    Image           Logitech QuickCam 3000                                                           USB\VID_...
Unknown    Image           Brother DCP-9022CDW [3c2af42c08de]                                               SWD\DAFW...
Unknown    Camera          HTC Vive                                                                         USB\VID_...

However, again, this only applies to very old hardware and it will also catch non-camera devices, like the multi-function printer above.

Daniel B
  • 60,360
  • 9
  • 122
  • 163
  • I suspect nearly every 'laptop' webcam's connected via USB. In theory a RPi style direct connection is possible but its something that I've never seen in the wild - which is likely why there's no 'obvious' difference – Journeyman Geek Feb 14 '23 at 15:19
  • 4
    Note: Both of these commands only show the internal camera on my laptop, not the external one connected by USB. – Gerald Schneider Feb 15 '23 at 07:22
  • 1
    They do show any external camera devices, as visible in the example output. – Daniel B Feb 15 '23 at 09:06
  • 5
    Not on my machine. I'm not saying the command is wrong, I'm just saying you should not rely on it to show all devices that are actually connected. There could be more. My Logitech webcam is registered as class "Image" instead of"Camera". – Gerald Schneider Feb 15 '23 at 11:14
  • 6
    Modern webcams, which all use the USB Video Class (UVC), will show up in the _Camera_ class. You are right that older cameras with proprietary drivers may show up in the Image category. I’ll adapt my answer. – Daniel B Feb 15 '23 at 19:04
7

PowerShell looks like a good option. From Use PowerShell to discover laptop webcam a couple of options are given.

The one that worked for me is

Get-CimInstance Win32_PnPEntity | where caption -match 'cam'

You may have to run the command a few times with variations of "camera" or "cam" or other terms that can catch all the various options. My camera for example is a Microsoft LifeCam that will not be seen if you search for "camera"

You might be able to see more if you modify your search to look for

Get-CimInstance Win32_PnPEntity | where PNPClass -match 'Image'

Which would show you all imaging devices and may include scanners and other devices.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Mokubai
  • 89,133
  • 25
  • 207
  • 233
  • 2
    The first command is the only one listed here that shows both of my cameras, internal and external; the second command only shows my external cam, but not the internal. – Gerald Schneider Feb 15 '23 at 07:23
6

I haven't extensively tested this but

Get-PnpDevice -PresentOnly | Where-Object { $_.Class -match '^Camera' } seems to work - kinda started with this SO answer and adjusted to fit

It'll also give you the name of the camera model under 'friendly name'

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430