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. The “CLEANUP-IMAGE /RESTOREHEALTH” command is not executed.

    in Windows 10 Gaming
    The “CLEANUP-IMAGE /RESTOREHEALTH” command is not executed.: In windows PowerShell window I tried to run the following command:PS C:\WINDOWS\SYSTEM32>DISM /ONLINE /CLEANUP-IMAGE /RESTOREHEALTHWhen I tried to execute the above command the following error message showed:Error: 0x800f081fThe source files could not be found.Use the...
  3. The “CLEANUP-IMAGE /RESTOREHEALTH” command is not executed.

    in Windows 10 Software and Apps
    The “CLEANUP-IMAGE /RESTOREHEALTH” command is not executed.: In windows PowerShell window I tried to run the following command:PS C:\WINDOWS\SYSTEM32>DISM /ONLINE /CLEANUP-IMAGE /RESTOREHEALTHWhen I tried to execute the above command the following error message showed:Error: 0x800f081fThe source files could not be found.Use the...
  4. USB connected devices not shown in One Commander

    in Windows 10 Software and Apps
    USB connected devices not shown in One Commander: I use One Commander because I find the two panes very convenient. However, it seems it has a serious handicap. It doesn't show as a drive connected devices via USB such as cameras or Android phones, which File explorer does. Is it so, or I just don't know how?...
  5. 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...
  6. 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...
  7. 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...
  8. 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?...
  9. 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?...
  10. 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?...