Windows 10: Old devices and driver cleanup (one command)

Discus and support Old devices and driver cleanup (one command) in Windows 10 Performance & Maintenance to solve the problem; Found this little gem of a command today. Wanted to share it with you. Nice to schedule this as a task running once a month? Rundll32.exe... Discussion in 'Windows 10 Performance & Maintenance' started by tweakradje, Feb 1, 2020.

  1. Old devices and driver cleanup (one command)


    Found this little gem of a command today. Wanted to share it with you. Nice to schedule this as a task running once a month?

    Rundll32.exe c:\windows\system32\pnpclean.dll,RunDLL_PnpClean /DEVICES /DRIVERS /FILES [/MAXCLEAN]
    For pnpclean output see c:\windows\inf\setupapi.dev.log

    PNPCLEAN [/DEVICES] [/DRIVERS] [/FILES] [/MAXCLEAN] [/NOREMOVE] /? /help /h

    /DEVICES Removes devices missing for the default time period
    /DRIVERS Removes redundant drivers from the system
    /FILES Removes files/directories that are no longer needed that are related to devices and drivers.
    /MAXCLEAN Performs maximum cleanup
    For /DEVICES this will set the time period to 0 so that every missing device will be processed for removal. (Note: Default missing device timeout period is 30 days!!!)
    For /DRIVERS this will allow every driver that is not installed on some device to be processed for removal.
    For /FILES this currently has no effect on what is removed.
    /NOREMOVE Evaluate items only, do not remove

    Did some testing and using it without /MAXCLEAN is probably best for using it in Task Scheduler once a month.

    Cheers

    :)
     
    tweakradje, Feb 1, 2020
    #1

  2. Old devices and driver cleanup (one command)

    Found this little gem of a command today. Wanted to share it with you. Nice to schedule this as a task running once a month?

    Rundll32.exe c:\windows\system32\pnpclean.dll,RunDLL_PnpClean /DEVICES /DRIVERS /FILES [/MAXCLEAN]
    For pnpclean output see c:\windows\inf\setupapi.dev.log

    PNPCLEAN [/DEVICES] [/DRIVERS] [/FILES] [/MAXCLEAN] [/NOREMOVE] /? /help /h

    /DEVICES Removes devices missing for the default time period
    /DRIVERS Removes redundant drivers from the system
    /FILES Removes files/directories that are no longer needed that are related to devices and drivers.
    /MAXCLEAN Performs maximum cleanup
    For /DEVICES this will set the time period to 0 so that every missing device will be processed for removal. (Note: Default missing device timeout period is 30 days!!!)
    For /DRIVERS this will allow every driver that is not installed on some device to be processed for removal.
    For /FILES this currently has no effect on what is removed.
    /NOREMOVE Evaluate items only, do not remove

    Did some testing and using it without /MAXCLEAN is probably best for using it in Task Scheduler once a month.

    Cheers
     
    tweakradje, Feb 1, 2020
    #2
  3. Old devices and driver cleanup (one command)

    Another command to get rid of older drivers (in c:\windows\system32\driverstore) that I used befor in a script is:

    For /f %%P in ('dism /online /get-drivers /format:table^|Findstr oem') do pnputil.exe /d %%P

    But it is limited to 3rd party drivers and doesn't remove "disconnected" devices. To get that done I used a little util called DeviceCleanupCmd.exe that also can remove "disconnected" devices that are not used within a given time frame.

    PnPClean.dll does it all in one command. It is not limited to Windows 10. Windows 2012R2 also has it. But then without the /FILES option.
     
    tweakradje, Feb 1, 2020
    #3
  4. Naki Win User

    Old devices and driver cleanup (one command)

    GPU-Z what command line parameter ?

    Suggestion: /? (-?) and /help (-help) command-line arguments to show a list of all possible arguments in a small window. *Smile Old devices and driver cleanup (one command) :)
     
    Naki, Feb 1, 2020
    #4
Thema:

Old devices and driver cleanup (one command)

Loading...
  1. Old devices and driver cleanup (one command) - Similar Threads - Old devices driver

  2. Is there a command to tell Device Manager to search for drivers for a device?

    in Windows 10 Installation and Upgrade
    Is there a command to tell Device Manager to search for drivers for a device?: I run a computer repair business and I see a lot of the same computers come through. I have an MDT server with the most common drivers on it. I don't always deploy images from that server, so when I do a clean install, I'd like to automatically install drivers that I've...
  3. Is there a command to tell Device Manager to search for drivers for a device?

    in Windows 10 Gaming
    Is there a command to tell Device Manager to search for drivers for a device?: I run a computer repair business and I see a lot of the same computers come through. I have an MDT server with the most common drivers on it. I don't always deploy images from that server, so when I do a clean install, I'd like to automatically install drivers that I've...
  4. Is there a command to tell Device Manager to search for drivers for a device?

    in Windows 10 Software and Apps
    Is there a command to tell Device Manager to search for drivers for a device?: I run a computer repair business and I see a lot of the same computers come through. I have an MDT server with the most common drivers on it. I don't always deploy images from that server, so when I do a clean install, I'd like to automatically install drivers that I've...
  5. Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages

    in Windows 10 Drivers and Hardware
    Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages: Good Day, The Disk Cleanup & Storage Settings were unable to delete Old Device Driver Packages. I have already performed basic troubleshooting & fixes but still same result. Is there other methods that I can perform to remove Old Device Driver Packages?...
  6. Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages

    in Windows 10 Gaming
    Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages: Good Day, The Disk Cleanup & Storage Settings were unable to delete Old Device Driver Packages. I have already performed basic troubleshooting & fixes but still same result. Is there other methods that I can perform to remove Old Device Driver Packages?...
  7. Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages

    in Windows 10 Software and Apps
    Disk Cleanup & Storage Settings Unable to Delete Old Device Driver Packages: Good Day, The Disk Cleanup & Storage Settings were unable to delete Old Device Driver Packages. I have already performed basic troubleshooting & fixes but still same result. Is there other methods that I can perform to remove Old Device Driver Packages?...
  8. Windows 10 keeps reinstalling drivers to old ones.

    in Windows 10 Drivers and Hardware
    Windows 10 keeps reinstalling drivers to old ones.: Hello. I'm using modded Nvidia GPU drivers, it works perfectly fine but after few days windows automatically install some old one and overwrites mine. Is there any way to stop this?...
  9. Backup all Device Drivers in Command Promt Admin

    in Windows 10 Installation and Upgrade
    Backup all Device Drivers in Command Promt Admin: Hi I needsome help,I'm trying to backup all device drivers in command prompt admin,using DISM /online /export-driver /destination: C:\DriverBackup after press ENTER,is an error 87 that say the destination path F:\ Drivers Backup does not exist. how can I do it?...
  10. Cleanup orphan/hidden devices

    in Windows 10 Performance & Maintenance
    Cleanup orphan/hidden devices: I have been following this thread, trying to fix the problem with the erroneous USB flask disks icons. According to the fix recommendation -which worked perfectly- there is a need to clear all phantom USB/Volume/Portable Devices from Device Manager. That is a cumbersome...