oemxx.PNF 是卸载不了驱动，应该使用 SetupUninstallOEMInf 函数。在 vista 以上平台
-f -d 可以强制删除。传递
You should use the SetupUninstallOEMInf function to uninstall the .INF (and subsequently .PNF) files. This will take care of the details. pnputil
(on Vista and higher) should do the equivalent thing from the command line. However, this function will not delete drivers that are currently installed (e.g. associated with a devnode).
Why are you uninstalling the old driver first? The user might already installed your driver for at least one devnode. Why not use a Microsoft-sanctioned solution such as DpInst
? It will do the work required to update the driver.
wouldn’t be a good idea, cause you’d end up with lingering .INF references in your devnodes (in the registry).
At work I wrote a utility I called DriverUninstaller that deletes the devnodes and then deleted the INFs. I only use this utility for uninstallations. Upgrades are handled by DpInst, as they should be. The flow is roughly:
- Enumerate them with SetupAPI (e.g. by device class if your device class is unique)
- For each devnode, call
to find all .INF files for my device
- For each INF, call