Driver store clean uninstallation and installation

Used Dpinst.exe for upgrading the drivers. Lets say x version to y version. Viseversa. Old versions “x” driver files are still available in driverstore even after upgrading to y version. X n Y version respective driverstore path still can be seen in setup api logs. Is there any better way to clean up / delete the driverstore old driver files. Or better way of install or upgrade the drivers. By the way manual installation from device manager or inf install still works fine. Only problem with Dpinst.exe.

I use this to clean up after installations [ https://github.com/lostindark/DriverStoreExplorer ] without leaving a ton of OEM.inf’s lying about (yes, I know if they are signed you don’t get OEM’s but I’m lazy) :smile:

It also comes with source, which makes it handy if you’re making your own installer like a deployable kernel service inside of a usermode service …

All successfully imported 3rd party INFs results in an OEMXxxx.inf being generated. Signing state of the INF is irrelevant. I am not familiar with the 3rd party tool, but if the tool is touching driver store state outside the driver store APIs, you are putting your system into an unsupported and internally inconsistent state.

I had understood (probably incorrectly) that having a MS signature would not result in an OEMxx file, but having an internally generated signature (so you need to have testmode enabled) will generate OEMxx files … at least that’s been my empirical experience

The tool uses standard DiXX functions, which I [assume] will maintain the proper state …

You misunderstood. Essentially every INF needs a unique name. When constructing the OS and all first party INFs, this can be enforced at build time. For dynamically added third party INFs, it is the wild west in terms of file naming and INF names can easily conflict between two disparate companies (and if the package was copied from a sample, highly likely). So, each third party INF gets its own unique OEMXxxx.inf file name. The key here is successful import of the driver package.

PnPUtil apparently has a feature that allows you to delete driver packages properly. I say apparently because I’ve never tried it. It seems like every time I fool with PnPUtil it either (a) does something I don’t want it to do, or (b) doesn’t do what I do want it to do. But, you know, that’s just me.

Peter

1 Like

As long as you have the initial .inf file from the old driver (with the .sys and .cat file) you can use dpinst.exe to uninstall your old driver:
for example: DPInst.exe /sw /se /sa /q /u YourInitial.inf

With pnputil you need to know the actual oem##.inf filename from the driver store.

  • Use pnputil /enum-drivers to find that oem##.inf filename.
  • Use pnputil /delete-driver oem##.inf /force to delete the driver

We use both methods a lot and they usually work just fine. In rare cases the above doesn’t work and you must reboot the computer to delete the driver from the driver store.

1 Like

PnPUtil it either (a) does something I don’t want it to do, or (b) doesn’t do what I do want it to do.

That’s interesting – I have switched completely from devcon to pnputil because with devcon I kept getting two instances of my devices in Device Manager. Luck of the draw, I suppose.

For those who prefer command line, you can use the following utility. pnputil does not work well under Vista and that was the motivation that Travis Robinson (author of libusbk and libusbdotnet) wrote this last time.
https://github.com/mcuee/PnpFind

I created this powershell script for this exact purpose, you may have to manually uninstall one more time to get back to a non-driver state. NOTE: replace xx with your driver name.

**NOTE: ** start-process is commented out, which will let you see what’s getting removed prior to running. Use at your own risk. I will not respond to support requests.

#
# Remove-All-xx-Drivers.ps1
# Purpose:  If you only update your driver, and never uninstall.  weird behavior can occur after the 200th install.
#           Run this script to do a cleanup.  Reboot after.
#
# PreRequisite:  run, pnputil -e > c:\pnputil.out
#
# Published name :            oem2.inf
# Class :                     xx

$stream_reader = New-Object System.IO.StreamReader{c:\pnputil.out}
$line_number = 1
$savedINF = ''
while (($current_line =$stream_reader.ReadLine()) -ne $null)
{
   if ($current_line -like '*oem*.inf*')
      {
         # found one, save it off.   we'll delete it if Class is xx
         $header, $savedINF = $current_line -split ':'
         $savedINF = $savedINF.replace(' ', '')
         #write-host ".$savedINF."
      }
   if ($current_line -like '*xx*')
      {
         # found an xx driver, let's whack it.
         if ($savedINF -ne '')
            {
               write-host "Deleting $savedINF($current_line)"
               #$p = Start-Process pnputil -wait -NoNewWindow -PassThru -ArgumentList "-f", "-d", "$savedINF"
               $p.HasExited
               $p.ExitCode
            }
            else
               {
                  # spit out an error for what we found.
                  write-host "found line=$current_line, but INF was blank"
               }
      }
}