Repairing Windows System Files

There are some base systems files that Windows must have to operate and to do so efficiently.   For some time now there has been a utility to check these files and report on their well-being.  This System File Check utility will check for damaged or corrupted files and repair what it can.   You only need to run it from an elevated command prompt with the command “SFC /scannow”.  The will initiate a complete of all the essential protected system files that would compromise your computer.

SFC /scannow

It, however, cannot always fix the problems on your system.  Sometimes this due to Windows updates and sometimes it is due to other issues.  When System File Checker cannot fix the system files there is a utility for Windows 8 and up called DISM.   The utility will check the files not only with internal checksums but with checksums over the internet from Microsoft.   There is a scan only option and a restore option.  You can use the restore blindly without scanning but if you want to see if there is anything first you should use the /scanhealth option.  You can run them back to back or use a single command line that will do if for you.

Back to Back would be:

DISM /Online /Cleanup-image /Scanhealth

DISM /Online /Cleanup-image /Restorehealth

Or both together:

DISM /Online /Cleanup-image /Scanhealth && DISM /Online /Cleanup-image /Restorehealth

(there is a space both before and after the &&)

 DISM takes care of matching and fixing files based on what’s current on the Microsoft cloud but SFC is still the go to file checker.  I would recommend running SFC then DISM then SFC once more to check that there are no more errors.  Running SFC first will probably fix most of (if any) errors on your system but if it gives and error you then use DISM as a backup.  Once finished with DISM you run SFC again to see if there are any unresolved errors left.

Both SFC and DISM can take some time to run depending on errors found and corrected.  So, I would recommend doing them when you have down time that you wouldn’t need your computer.

 

Extremely long file names and directory paths.

File Name too long?  Or perhaps along with the directory path it’s too long?

 When copying files for backup from long directory paths you have probably come across an error, every so often, that says something like “directory path too long would you like to skip this file?”.  The reason for this is that you are usually only allowed a maximum of 244 characters in the file name so copying a path which has over 244 characters in the name fails.  This does not happen often but sometimes with networks and programs that tend to nest subdirectories names can become too long for this rule.   With the introduction of Windows 10 (starting at revision 1607) Microsoft removed this limitation. However, this is not enabled by default to maintain compatibility.  You must opt-in for this feature to work.   There are two ways to do this, from the Registry or from the Group Policy editor (Not included in Windows Home).

For those of you that have Windows 10 Pro or above you can open the Group Policy Editor and navigate to Computer Configuration > Administrative Templates > System > Filesystem > Enable NTFS long paths and set it to Enabled.

For any version of Windows 10 (including Home) you can make a Registry change.  Always remember that registry changes can damage your computer to the point of completely ruining it.  Do not make these changes unless you are comfortable with it.

You will need to navigate to:  HKLM\SYSTEM\CurrentControlSet\Control\FileSystem and look for the DWORD: LongPathsEnabled if it is not there, create it as a REG_DWORD 32 Bit. The default value is 0 which is compatibility.  If you change its value to 1 then you will have enabled unlimited File/Path lengths.

I am adding a link to a zip file which has two Registry file modifiers which will do this automatically for you.  Just unzip the files and run the ExtendedFileNames_on to switch it to on and ExtendedFileNames_off to turn it back off.

Extended path / file length registry entry