Can I uninstall a device driver through an INF section?

Solution 1:

Well it depends on the .inf file (some may not have un-installation function at all), but you could always try one of the following:

rundll32 setupapi.dll,InstallHinfSection DefaultUninstall 132 <driver.inf>

rundll32 advpack.dll,LaunchINFSection <driver.inf>,UnInstall

rundll32 syssetup.dll,SetupInfObjectInstallAction Uninstall.NT 4 <driver.inf>

(Of course, replace the filename, including quotes as necessary.)

Solution 2:

No, driver INF files do not typically feature an uninstall section. As per How to remove .inf files from the system and How Devices and Driver Packages are Uninstalled | Microsoft Docs , DiUninstallDevice and SetupUninstallOEMInf are the ways to uninstall a device and a driver package, correspondingly.

From the console, you can call the latter with devcon of at least version 6 (from Windows 8.x DDK; confirmed to work in XP):

devcon [-f] dp_delete oemXXX.inf

(-f forces uninstallation even if the driver is in use)

See Quick Method to install DevCon.exe? how to download the utility if you need to do this by hand.

From an installer package, you need to use facilities provided by the installer framework that would call those API for you.