Can I uninstall a device driver through an INF section?

13,199

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.

Share:
13,199

Related videos on Youtube

coelhudo
Author by

coelhudo

Updated on September 18, 2022

Comments

  • coelhudo
    coelhudo almost 2 years

    At MSDN it is stated that there are two techniques to install INF files on Windows XP or later:

    • Programmatically through SetupCopyOEMInf function.
    • Add an entry called CopyInf on an INF section.

    Are there an equivalent entry on an inf section to uninstall inf files that is similar to SetupUninstallOEMInf function?

    I found this solution using SetupUninstallOEMInf but it does not seems suitable to me.

  • coelhudo
    coelhudo almost 12 years
    Right, but I didn't find any entry that explicitly remove oemXX.inf generated by CopyInf entry. I am able to remove *.sys files that was copied to %SystemRoot%\System32\drivers with CopyFiles entry. There is Delfiles entry but only works when I know which files I need to remove.
  • Synetech
    Synetech almost 12 years
    Are you asking about oem*.inf being automatically removed from \Windows\INF? I have never seen that happen, especially with things that are installed via .inf files instead of .exe or .msi installers. You could open them in a text-editor and delete the one(s) that no longer apply.
  • coelhudo
    coelhudo almost 12 years
    Yeap, I need this to be integrated into a NSIS (the installer from nullsoft) script. It has to be executed automatically when my app is uninstalled.
  • Synetech
    Synetech almost 12 years
    Ah, I see. Well if you are writing your own (un)installer, then just add a line to delete the .inf file. You can query the InfPath value of the device in question under the HKLM\SYSTEM\ControlSet001\Control\Class registry branch to find out what the oem*.inf filename is for it.
  • coelhudo
    coelhudo almost 12 years
    I didn't find anything similar to the oem*.inf in that registry branch (windows xp and windows 7) tat was generated while installing. Is there any other place where I can find the corresponding oem name?
  • Synetech
    Synetech almost 12 years
    Are you sure the device was installed? Are you sure there is an oem*.inf file? Do a search in \Windows\inf` for oem*.inf` files taht contain the device name (or just check them all in notepad if there’s only a few).
  • ivan_pozdeev
    ivan_pozdeev over 6 years
    I've yet to see a driver installation .inf (unlike .infs that install some system components) that has an uninstallation section. So these commands are utterly useless.
  • kellogs
    kellogs over 3 years
    where oemxxx.inf is not the same inf that you have installed from; use devcon dp_enum for a list to installed oem*.inf files