try running this with admin rights.
# stopping services....
net stop wuauserv
net stop cryptSvc
net stop bits
net stop msiserver
#clean the temporary files...
del "%tmp%" /s /q
del "%temp%" /s /q
del C:\*.tmp /s /q
del C:\users\*\AppData\Local\Temp\* /s /q
del C:\Windows\Temp\* /s /q
# check the OS with DISM.exe
# /Restorehealth to repair the corrupted scanned files
# /Cleanup-image to cleanup and repair the system.
# /Online you tell DISM to use the current OS and not an image.
# /ResetBase to removes all superseded component in the component store
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
#Rename the SoftwareDistribution and System32\catroot2
net stop cryptsvc
rename %systemroot%\system32\catroot2 catroot2_old
rename %systemroot%\SoftwareDistribution SoftwareDistribution_old
#Remove "C:\$WINDOWS.~BT"
takeown /F "C:\$WINDOWS.~BT" /R /A
icacls "C:\$WINDOWS.~BT\*.*" /T /grant administrators:F
rmdir /S /Q "C:\$WINDOWS.~BT\"
#Remove "C:\$Windows.~WS"
takeown /F "C:\$Windows.~WS" /R /A
icacls "C:\$WINDOWS.~BT\*.*" /T /grant administrators:F
rmdir /S /Q "C:\$WINDOWS.~BT\"
net start wuauserv
net start cryptSvc
net start bits
net start msiserver
exit