Forcing Windows to re-scan for drivers - windows

As part of our software's installation, we install drivers for a required 3rd party hardware component. Currently it's up to the user to manually scan for their hardware's drivers once our installation is completed.
Is there an easy way to get Windows to automatically look for the drivers we installed? If so, how does it work? Do we need to tell the OS for which hardware device we have drivers, or just that we have drivers in a certain location? Or can we just install the drivers to System32 folder and trigger a driver rescan?

So the hardware is already plugged in when you install the driver?
Download the Windows Driver Kit (WDK) and see the devcon sample (binary and source included). The "devcon update" command should do what you want (i.e. install the drivers and then load them over the specified device instance).
-scott

Related

Without installing FTDI driver, can an application dependent on it be deployed?

I am developing a Win10 C# application dependent on a third party library, which enables me to control a USB3 device.
By trial and error, I found that I needed to run FTD3XXDriver_WHQLCertified_v1.3.0.4_Installer.exe, which in the end populated the SysWOW64 with FTD3XX.dll and System32\Drivers with FTDIBUS3.sys and the ancillary files and folder.
I would like to run my application from a USB thumb drive on different PC's in my organization without installing any of the drivers. Is there a way to do that?
Bad news: To the best of my knowledge you cannot address an FTDI device if the driver is not installed.
But windows normally install the driver automatically via the windows updater. At least, this is the case for the USB 2 devices of FTDI i.e. 232 family. I do not have a FT60X here to test if the windows updater has a driver ready for this as well.
If the driver is installed via the updater you have to bundle the FTD3XX.DLL with your application as it is not part of the "windows standard" driver. At least this was the case for the FTD2XX.DLL.
Long story short: connect your device to a computer without preinstalled driver. Check if the driver is installed via the windows updater. If this is the case, you mostlikely just need to bundle the FTD3XX.DLL with you application.

Pre-install driver on Windows

I am trying to create an installer (using Inno Setup) that will pre-install a USB driver for an LCD HMI. I have the drivers from the manufacturer (they appear to be signed). However, no matter what I do, Windows will first detect the driver as a "Gadget Serial v2.4" device, then immediately go to "Windows Update" and downloads a "PNX Bulk Device" driver.
This driver does not work with the HMI. I have to then manually open up Device Manager, find the "PNX Bulk Device", go to "Update Driver Software"..."Browse My Computer", "Have Disk", etc.
This is a very arduous process and may be overwhelming for an inexperienced user.
Is there anyway to automate the process, such that if the package is installed before the USB device is plugged in, then the driver will be in place, and Windows will use the correct driver rather than the Generic ones it is finding?
Note: I have tried the DPInst utility, the SetupCopyOEMInf function and pnputil.exe. All methods "appear" to work (ie: no error messages), but Windows still grabs the generic driver first, no matter what.
I realize my understanding of drivers may be flawed. I'm trying this on a Windows 7 x64 architecture, but I would like it to work universally.

Is it possible to fully install a driver when the device is not present?

Is it possible to fully install (and not just pre-install) a device driver on a system before the physical device is plugged in? In particular, I'm looking at the D2XX drivers by FTDI. Their driver installation program effectively runs dpinst.exe, and if you watch the console output of that program it says this:
No matching device was found for 'c:\drivers\ftdiport.inf'. Driver will be installed when plugged in.
The trouble is that I'm also using their .NET library for accessing the device, and that library is funny. It pops up an alert in the constructor if the driver isn't installed. Of course the usual solution is to simply plug in the device and let the driver installation finish as normal, but sometimes this is neglected. The pitfalls with having an unavoidable popup box in a 3rd party library should be obvious.
So does anyone know of a way to automate the full installation, and not just the pre-installation? Are there any dangers to copying the driver to the system folder manually / in advance?
You seem to mention "fully install" by "staging" the driver not by "loading" the driver. You can refer to the source code of "devcon.exe" for dp_add command, which actually do staging the driver package. Staged driver package will be being searched by PnP Manager when the unknown device is detected.

Install driver without plugging in device

I'm trying to install some unsigned legacy drivers to my computer from command line. I have used dpinst.exe and installhinfsection functions which work fine, however everything I've tried is software first, meaning it installs the driver onto your computer and then doesn't actually show up in the device manager until you plug the device into your computer.
I'm wanting to install the driver and have it show up in the device manager without having to plug in any devices.
I can do this with adding legacy hardware from the device manager, but I want this to be an automated process so all from command line and not having to do it manually through device manager.
thanks in advance
EDIT
The drivers were written by me (UserModeDriverFramework), they are emulating real devices.

Remove incorrect binding of composite device to custom driver

Our latest WHQL'ed custom driver has an incorrect entry for one of our upcoming product. The upcoming product is composite device and our WHQL'ed driver has an entry which matches the device ID for the composite device instead of the individual interfaces.
When the new device is connected to machines which have the WHQL'ed driver, the device gets binded to our driver and not to Windows Generic Parent Driver (usbccgp.sys). This prevents the interfaces in the device from being listed.
We could manually fix this by uninstalling the driver for the device and making it to bind to usbccgp.sys driver. In Vista and higher versions, we could delete the driver binaries at the time of uninstall. But there is no direct way to completely delete the driver binaries in XP. This makes it very difficult to cleanly uninstall the driver
Can this be fixed using an uninstaller? What is the best way to fix the affected machine in an automated way?
Download the Windows Driver Development Kit (Win DDK) and locate the devcon.exe executable for your architecture. Then, from an elevated command prompt:
devcon.exe find =usb
To list all of your current devices.
devcon.exe -r remove =usb *YOUR_HARDWARE_ID*
Will complete disassociate the device and driver from the target machine. If you have trouble getting the hardware id you can blow away all your USB drivers and let Windows auto-detect them after reboot.
devcon.exe -r remove =usb *
Extreme, yes. Effective, yes. We work with virtual comm ports all day and our test machines often experience your same issue. This technique has yet to fail.

Resources