Search code examples
c#c++windowsreal-timedevcon

Update driver for one of the same model network adapters


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.


Solution

  • 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.