Windows: Unload/Disable a device driver from command line

Hi,

like Linux rmmod Windows can also unload a device driver “online”.

In later Windows release the command devcon.exe from the Windows Device Driver Kit was used for such tasks.

Newer Windows versions have the pnputil.exe command line tool.

An example: Windows PE is running and you want to remove a disk attached from SAN. The Host Bus Adapter is an emulex.

Find all instances

X:\> pnputil /enum-devices
Instance ID:                PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0010
Device Description:         Emulex LightPulse HBA - Storport Miniport Driver
Class Name:                 SCSIAdapter
Class GUID:                 {4d36e97b-e325-11ce-bfc1-08002be10318}
Manufacturer Name:          Emulex
Status:                     Started
Driver Name:                elxstor.inf

Instance ID:                PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0110
Device Description:         Emulex LightPulse HBA - Storport Miniport Driver
Class Name:                 SCSIAdapter
Class GUID:                 {4d36e97b-e325-11ce-bfc1-08002be10318}
Manufacturer Name:          Emulex
Status:                     Disabled
Driver Name:                elxstor.inf

And disable the driver

X:\> pnputil /disable-device "PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0010"
Microsoft PnP Utility

Disabling device:          PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0010
Device disabled successfully
X:\> pnputil /disable-device "PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0110"
Microsoft PnP Utility

Disabling device:          PCI\VEN_10DF&DEV_F100&SUBSYS_F10010DF&REV_03\4&1d78c88&0&0110
Device disabled successfully

The (disk) device could also removed temporarily. For example to get a new diskpart disk number.

In this example a Disk handled by a MegaRaid SR driver.

X:\> pnputil /remove-device "SCSI\Disk&Ven_LSI&Prod_MegaSR__\4&12c2d723&0&020000" 

Then rescan for disks

X:\> diskpart
DISKPART> rescan

Michael

Leave a Reply