How Devices and Driver Packages are Uninstalled
This page describes how software uninstalls a device and removes a driver package from the driver store.
Uninstalling the Device
To remove the device node (devnode) that represents a physical device, use one of the following:
To uninstall only the specified device, use a device installation application that calls the SetupAPI function SetupDiCallClassInstaller with a request of DIF_REMOVE.
To uninstall the specified device and any devices below it in the device tree, use a device installation application that calls the DiUninstallDevice function.
When a device is uninstalled using one of these methods, the Plug and Play (PnP) manager removes the association between the driver binary files and the device.
The device remains in the kernel PnP tree and the driver package remains in the driver store. If the PnP manager re-enumerates the device (for example if the device is unplugged and then plugged in again), the PnP manager treats it as a new device instance and installs the driver package from the driver store.
For info on how an end user can uninstall a device, see Using Device Manager to Uninstall Devices and Driver Packages.
Deleting a Driver Package from the Driver Store
To delete a driver package from the driver store, you must:
- Ensure no devices are installed with the driver package.
- Remove the driver package from the driver store.
To perform both of these steps with one action, you can do one of the following:
- Starting in Windows 10, version 1607, from the command prompt, use
pnputil /delete-driver <example.inf> /uninstall
. For info on PnPUtil commands, see PnPUtil Command Syntax. - Starting in Windows 10, version 1703, a device installation application can call DiUninstallDriverW.
On Windows 10, version 1511 and earlier:
- Identify all devices currently installed with the driver package and update them so that they do not depend on the driver package. You can do one of the following:
- Install a different driver package on the device.
- Use DiInstallDevice with the
DIIDFLAG_INSTALLNULLDRIVER
flag to install the null driver on the device. - Uninstall the device.
- The device installation application then calls SetupUninstallOEMInf to remove the driver package.
Deleting a driver package from the driver store removes associated metadata from the PnP manager's internal database and deletes related INF files from the system INF directory.
After the driver package has been removed, it is no longer available to be installed on a device. To reinstall, download the driver package again from the original source, such as Windows Update.
Manually deleting the driver package from the driver store may result in unpredictable behavior.