PNPUTIL - CMD


Overview

The PNPUTIL command in Windows Command Line is a Device Driver Package manager that allows users to manage the driver store. It provides functionalities to add, remove, and list driver packages previously installed in the system. This tool is mainly used by system administrators and IT professionals to ensure the correct drivers are installed, backed up, or restored as needed in Windows operating systems.

Syntax

pnputil [Options]

Where [Options] can be a combination of the following:

  • /add-driver <driver.inf>
  • /delete-driver <driver.inf>
  • /enum-drivers
  • /export-driver <driver.inf>
  • /enum-devices
  • /remove-device
  • /restart-device
  • /scan-devices

Each option may have additional parameters and must be chosen based on the specific task.

Options/Flags

  • /add-driver <driver.inf>: Adds the specified driver to the driver store. Can specify multiple .inf files. Use /subdirs to include subdirectories.
  • /delete-driver <driver.inf>: Deletes the driver package from the store. Use /force to force deletion ignoring any errors.
  • /enum-drivers: Lists all driver packages in the driver store.
  • /export-driver <driver.inf>: Exports the specified driver package to a file or directory.
  • /enum-devices: Lists all devices currently on the system.
  • /remove-device: Removes the specified device from the system.
  • /restart-device: Restarts the specified device.
  • /scan-devices: Scans for new devices and attempts to install drivers if needed.

Examples

  1. Adding a Driver:

    pnputil /add-driver C:\Drivers\example.inf
    

    Adds the example.inf driver to the driver store.

  2. Deleting a Driver:

    pnputil /delete-driver example.inf /force
    

    Force deletes the example.inf driver from the driver store.

  3. Listing All Drivers:

    pnputil /enum-drivers
    

    Displays a list of all drivers in the driver store.

Common Issues

  • Access Denied: Ensure you have administrator privileges. Run the command prompt as an administrator.
  • File Not Found: Check the paths to .inf files to ensure they are correct.
  • Driver in Use: Some drivers cannot be deleted because they are in use. Restart in safe mode and try again or use /force to override.

Integration

PNPUTIL can be combined with scripting to automate setup or teardown processes. For example, using a batch script to install multiple drivers:

for /R %i in (*.inf) do pnputil /add-driver "%i" /install

This script loops through all .inf files in the current directory and subdirectories, adding them to the driver store.

  • Device Manager (devmgmt.msc): Graphical interface to view and manage hardware devices.
  • DriverQuery: Displays a list of all installed device drivers and their properties.

Visit the Windows Command Line Documentation for more information on pnputil and other Windows commands: Microsoft Docs