Archive: 'scan for hardware changes' via NSIS?


'scan for hardware changes' via NSIS?
got a bit of an odd report, but that's Windows and devices for ya...

Our installer currently (pre-)installs a hardware device driver through DPInst, simply to prevent any specific tweaks needing to be made through Windows versions, 32bit vs 64bit, and all that. This works very well, so no problems there.

Then a curious user decides to remove the installed hardware device from the Device Manager. No problem.. if the user wants to be silly, that's totally up to them.

But then when they re-install the hardware device driver through the installer, instead of DPInst installing, it performs a pre-install. After all, it thinks the hardware is gone (the user removed it from the device manager).
Now personally I think this is pretty much expected behavior if the user forces this, and if the user scans for hardware after installation, it will use the pre-installed package just dandy.
But from a user-friendliness point of view, the expected behavior probably -is- that the device becomes available again after driver package installation.

So to solve this, I have to force the equivalent of the Device Manager's "scan for hardware changes" functionality - preferably without opening the device manager console and sending a mouseclick to the button ;)

The 'scanHardware' configuration flag for DPInst sounded 100% promising but of course what it actually means is 'scan the currently recognized devices and only install the package if it is a better match than the current package installed for that device'.

Neither the InstDrv plug-in nor 'Driver installation and update' wiki topics seem to touch on device list refreshing.

Which leaves me with the maze that is MSDN, which tells me I should be running what is explained here...
http://support.microsoft.com/kb/259697
whose functions are described in Cfgmgr32.dll
...through the System plugin.

Would that be the appropriate route to take, or is there a more obvious method that I glossed over?


You might want to have a look at the devcon tool from the Windows DDK:
http://support.microsoft.com/kb/311272

Though I'm not sure Vista or Win7 support this tool.


I forgot to mention that one...

1. Yes, the page doesn't say anything about Vista+ support

but even if it did, there's a dealbreaker in there

2.

DevCon is not redistributable. It is provided for use as a debugging and development tool.
emphasis mine

Originally posted by Animaether
DevCon is not redistributable. It is provided for use as a debugging and development tool.
Hmm, missed that.

Then I think your only option is to use the functions you mentioned in the first post.

Yup, seemed like it. Just wanted to double-check - thanks :)

Function calls are now implemented... I made a wiki page for it with fully annotated macro:
http://nsis.sourceforge.net/Scan_for_hardware_changes

I still wrestle with System sometimes, so if I'm using a wrong type somewhere.. please do (help) fix; as far as I can tell, though, it works.