By now it’s starting to become public knowledge that most of the the Windows 10 build 10122 upgrades that failed at the 18/62 percent mark can be fixed by opening a command prompt as system (via psexec -i –s cmd.exe), and run the following command (note: case sensitive):
rundll32.exe pnpclean.dll,RunDLL_PnpClean /DRIVERS /MAXCLEAN
Cred: Big thanks to Pieter Wigleven who first posted the fix here: http://blogs.technet.com/b/ems/archive/2015/05/21/installer-stuck-at-18-when-upgrading-from-windows-10-10074-to-10112.aspx and to Scott Hanselman and Stephen Rose for spreading the word.
Running the fix is a command prompt elevated to system.
So, what does the hack really do
The documentation around pnpclean.dll (Plug and Play Maintenance Task Library) is spare to say the least, but it is the same component being used by the native Disk Cleanup utility in Windows. So why doesn’t the native Disk Cleanup utility do the job when selecting to delete device driver packages then? Well, when looking into the pnpclean.dll, you can see the following info in process explorer (same as running the strings utility against the pnpclean.dll).
If you scroll further down in the strings windows you can see that the following strings:
Searching for unused drivers that may be removed from the system.
Will only keep drivers that are installed on some device.
From the information you can also see pnpclean.dll is logging to setupapi.dev.log as well as setupapi.app.log and setupapi.offline.log. Interesting enough there is also a loglevel property… The loglevels can be set by modifying the HKLMSoftwareMicrosoftWindowsCurrentVersionSetupLogLevel value (default is 0x20004001, maximum for devices is 0x0000FF00), more information in this post:
Setting SetupAPI Logging Levels
Setupapi.dev.log, with default logging level, showing the commands being run.
So again, why is it behaving different when launched via Disk Cleanup vs. launched manually?
So far (still investigating) it looks like the disk cleanup process, does not call the /MAXCLEAN option.
Tip: You can also automate the tasks that the Disk Cleanup utility does, see the following posts
Automating the Disk Cleanup Utility, by Greg Ramsey
Automating Disk Cleanup Tool in Windows
The error in Setupact.log without running the fix prior to upgrade.