Is there a Setup API to update the driver for a non-present Windows PnP device?

I want to update the driver for non-present PnP devices from a C program. Does anyone know how to do it (if it’s even possible)?

That’s something that I never had to do in any of my setup applications, but I can’t see an obvious reason why it should be impossible.

I suspect that UpdateDriverForPlugAndPlayDevices() will skip non-present devices just to avoid unnecessary work. And for DiInstallDriver() MSDN even explicitly says “installs the driver on devices present in the system”. But have you tried those two functions and observed their actual behaviour?

Then there’s DiInstallDevice(). Once again, MSDN says that it will install a driver on a “device that is present in the system”. But that device is specified via a SP_DEVINFO_DATA struct, and that’s something that you can obtain for non-present devices, too (by calling SetupDiGetClassDevs without the DIGCF_PRESENT flag). Have you tried that?

If you just need to replace the sys file, then just go ahead and copy it into place. If there are changes in the INF file, then you can uninstall the old driver and pre-install the new one. You don’t need UpdateDriverForPlugAndPlayDevices if there are no live devices to update. All you’re doing is updating the file system, and possibly the registry.