question

TheSherriff-0440 avatar image
0 Votes"
TheSherriff-0440 asked DanielZhang-MSFT edited

How to make a list of allowed/not allowed components (USB) of specific companies

hey evreyone :)

I want to make an list of specific keyboards and mouses that the user allowed to use.

I have some computers and it may be in the GP locally.

any one knows??

thank you so much for your help!!

Noam.

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

For you to allow or disallow a USB device the device needs a INF file that includes the following

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ManufacturerName% = Standard,NTamd64

[Standard.NTamd64]
%DeviceName% =USB_Install, USB\VID_0547&PID_1002

If the device does not then it's not possible to continue.

Next up, only managed code is with UWP applications - How to get USB descriptors

Prior to the above for UWP you need to use code like the following.

 public class WinDevices
 {
     static public List GetUSBDevices()
     {
         List devices = new List();
     
         ManagementObjectCollection collection;
         using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
             collection = searcher.Get();
     
     
         foreach (var device in collection)
         {
             var deviceInfo = new DeviceInfo();
             deviceInfo.DeviceID =       (string)device.GetPropertyValue("DeviceID");
             deviceInfo.PNPDeviceID =    (string)device.GetPropertyValue("PNPDeviceID");
             deviceInfo.Description =    (string)device.GetPropertyValue("Description");
             deviceInfo.Name =           (string)device.GetPropertyValue("Name");
             deviceInfo.Caption =        (string)device.GetPropertyValue("Caption");
             deviceInfo.Service =        (string)device.GetPropertyValue("Service");
             devices.Add(deviceInfo);
     
             // Other properties supported by Win32_PnPEntity
             // See http://msdn.microsoft.com/en-us/library/aa394353%28v=vs.85%29.aspx
             //var keys = new string[] {
             //        "Availability",
             //        "Caption",
             //        "ClassGuid",
             //        "CompatibleID[]",
             //        "ConfigManagerErrorCode",
             //        "ConfigManagerUserConfig",
             //        "CreationClassName",
             //        "Description",
             //        "DeviceID",
             //        "ErrorCleared",
             //        "ErrorDescription",
             //        "HardwareID[]",
             //        "InstallDate",
             //        "LastErrorCode",
             //        "Manufacturer",
             //        "Name",
             //        "PNPDeviceID",
             //        "PowerManagementCapabilities[]",
             //        "PowerManagementSupported",
             //        "Service",
             //        "Status",
             //        "StatusInfo",
             //        "SystemCreationClassName",
             //        "SystemName"
             //};
     
         }
     
         collection.Dispose();
         return devices;
     }
     
     public class DeviceInfo
     {
         public string Name              { get; set; }
         public string DeviceID          { get; set; }
         public string PNPDeviceID       { get; set; }
         public string Description       { get; set; }
         public string Caption           { get; set; }
         public string Service           { get; set; }
     }
 }




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.