1

There are multiple network adapters of the same model in the target computer. As below, they are all Intel I211.

PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A000
    Name: Intel(R) I211 Gigabit Network Connection
    Hardware IDs:
        PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03
        PCI\VEN_8086&DEV_1539&SUBSYS_00008086
        PCI\VEN_8086&DEV_1539&CC_020000
        PCI\VEN_8086&DEV_1539&CC_0200
    Compatible IDs:
        PCI\VEN_8086&DEV_1539&REV_03
        PCI\VEN_8086&DEV_1539
        PCI\VEN_8086&CC_020000
        PCI\VEN_8086&CC_0200
        PCI\VEN_8086
        PCI\CC_020000&DT_0
        PCI\CC_020000
        PCI\CC_0200&DT_0
        PCI\CC_0200
PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A100
    Name: Intel(R) I211 Gigabit Network Connection #2
    Hardware IDs:
        PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03
        PCI\VEN_8086&DEV_1539&SUBSYS_00008086
        PCI\VEN_8086&DEV_1539&CC_020000
        PCI\VEN_8086&DEV_1539&CC_0200
    Compatible IDs:
        PCI\VEN_8086&DEV_1539&REV_03
        PCI\VEN_8086&DEV_1539
        PCI\VEN_8086&CC_020000
        PCI\VEN_8086&CC_0200
        PCI\VEN_8086
        PCI\CC_020000&DT_0
        PCI\CC_020000
        PCI\CC_0200&DT_0
        PCI\CC_0200

How do I update driver for a specific one of these same model adapters by devcon, C++ or C#? For example, update by the unique device instance ID (ex: PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A100)

Thanks

EDIT: I've searched APIs for this but they all use hardware ID to update the driver, which will update all of the same model adapters' drivers. Ex: C++'s UpdateDriverForPlugAndPlayDevicesA and devcon's update command.

EDIT2: The motivation of this issue is that we are using an RTOS (real-time OS, RTX64) and we want to establish a real-time network communication (EtherCAT connection) with other devices by the RTOS. We need to update one of the adapters' driver to the driver provided by RTX64, so that this adapter can be used by it.

The only workable solution for us to just update one of them is using Windows' "Device Manager". (There's no same model adapters in the below picture, it's just shows how to update by device manager manually) enter image description here

We are asking our users to do this manual update after installing our software. It's not convenient for them. So we are trying to find an automatic way to do this.

Since Device Manager in Windows can do this, we suppose that there's an API can do this too.

Christopher
  • 8,956
  • 2
  • 14
  • 31
YantingChen
  • 638
  • 11
  • 12
  • 1
    What have you tried so far? Please show your attempts. [how-to-ask page](https://stackoverflow.com/help/how-to-ask) – nilsK Oct 23 '19 at 06:55
  • As the "EDIT" part of the question, we tried UpdateDriverForPlugAndPlayDevicesA and devcon, but they all failed to update just one of the adapters' driver. – YantingChen Oct 31 '19 at 05:11
  • @YantingChen We need a better problem decription then "does not work". – Christopher Oct 31 '19 at 15:35
  • Open up Device manager and check the location of the driver(s). Most likely if you update the driver for one card all the card will get updated since the drivers are all in the same folder in windows. – jdweng Oct 31 '19 at 16:19
  • @Christopher After calling the "UpdateDriverForPlugAndPlayDevicesA" API, all of the same model adapters' drivers are updated, which is not what I want. – YantingChen Nov 01 '19 at 03:25
  • With that new information, something is still confusing me: Do you want to install part of a realtime-application on a Windows? Windows is not a realtime-OS, so it would ruin the Real-Time part of the whole thing. At best you could run a controler/management/status programm that has no realtime constraints on that Windows. | One of the reason realtime programming is wierd and specialized, is because it does not adapt to hardware - it *dictates* the hardware. So changing the hardware to have only one of this adaptor is a entirely valid solution to this programming problem. – Christopher Nov 01 '19 at 15:01
  • @Christopher RTX64 and Windows will run on different CPU cores, so hard real-time for RTX64 can be assured. You may refer to RTX64's website for more information. – YantingChen Nov 04 '19 at 06:49

2 Answers2

1

This is not really a average Programmer Problem.

Driver Programming - as a subset of Realtime Programming - is a highly specialized field. The average C# or C++ .NET Programmer will rarely have to deal with stuff like pointers and neer with assembler level code. But for those two, it is their daily bread and butter. I can not give you little more then general advice:

My first advice for you is to get somebody elses code to make that decision and installation. Usually drivers of one Manufacturer are distributed in packages. Wich do understand how to deal with idenitifcation of the hardware. Usually those installers also have a silent mode. So it comes down to calling them and intercepting the console output/looking for the return value.

My second advice, is to use their name as listed in the Device Manager. Optionally get them renamed manually. It is not that reliable as strings are quite patient and easily changed/missmatched, but it would get you somewhere to start from.

But as I understand it your problem is worse then just general driver updates. You have two instances of the same Hardware, and want to use different drivers for each. Wich is a order worse:

  1. I am not even sure this is possible. Since the driver folder still uses the good old "only one file of each name" approach, it is propable that you can not use different drivers for different instances of the same hardware. Unless you define your own driver storage location.

  2. I have no idea why you would do that. The average enduser programm does not need to worry about even selecting wich interface it will use. It just hands it's request off the to network stack and does not deal with layer 3 or below. Servers may have to pick a specific adapter to listen on, or just listen on both in paralell. But even those do not care for the driver version in use. They do not even care if it is a real, physical interface - after all missclassification like with early Bluetooth and Virtual Devices like for Virtual Machine Monitors/PDF printers are a thing.

So it honestly sounds like you got a XY Problem, with this idea being the (propably wrong) Y, to your real X.

Christopher
  • 8,956
  • 2
  • 14
  • 31
1

Two workarounds. One minimizes manual customer interaction when updating the device driver, the other fully automates the process, but requires coding in a BASIC like language.

The first one consists on automatically showing the Hardware Update Wizard for that particular device instance, using the API function DiShowUpdateDevice as described in the previous link.

The second one is to use the free AutoIt automation software. With it you can automate basically everything in a Windows system, it's very powerful and I've used it in conjunction with web bots and automatic web testing (non-headless). I've also used it in double-click roll-outs of Windows systems and many sysadmin tasks.

As a remark, you could also mix both approaches. First, use DiShowUpdateDevice to show the wizard and then an AutoIt script can automatically perform UI interaction, the client won't have to do anything at all.

Javier Silva Ortíz
  • 2,426
  • 1
  • 8
  • 19
  • Thanks for the answer. Our clients may install our software on various versions of Windows (Windows 7, Windows 8, Windows 10, ...) with various Windows themes. Is AutoIt a reliable solution? – YantingChen Nov 04 '19 at 06:58
  • Sorry for the delay. Yes, AutoIt is a reliable solution, I've been using it since Windows XP. – Javier Silva Ortíz Nov 04 '19 at 23:11