@echo off TITLE Repairing Inf Cache rem change to drive where windows runs %SystemDrive% rem change to the \windows\inf folder cd %SystemRoot%\inf rem create random directory for backup set FOLDERNAME=infbk-%RANDOM% mkdir %FOLDERNAME% rem list of files which need to be removed set FILE1=INFPUB.DAT set FILE2=INFSTOR.DAT set FILE3=INFSTRNG.DAT set FILE4=INFCACHE.* set FILE5=SETUPAPI.* rem take ownership of the first file takeown /f %FILE1% rem grant full control to 'administrators' icacls %FILE1% /grant administrators:F /t rem move it to the backup folder move %FILE1% %FOLDERNAME% rem same for the other files takeown /f %FILE2% icacls %FILE2% /grant administrators:F /t move %FILE2% %FOLDERNAME% takeown /f %FILE3% icacls %FILE3% /grant administrators:F /t move %FILE3% %FOLDERNAME% takeown /f %FILE4% icacls %FILE4% /grant administrators:F /t move %FILE4% %FOLDERNAME% takeown /f %FILE5% icacls %FILE5% /grant administrators:F /t move %FILE5% %FOLDERNAME% echo Successfully moved all infcache related files to %FOLDERNAME% pause