Help - Search - Members - Calendar
Full Version: How To Use Sfc.exe To Repair System Files
BleepingComputer.com > Bleeping Computer Applications and Guides > Mini guides and how-tos - Simple answers to common questions > Microsoft Windows Mini-Guides
   
usasma
How to Use SFC.EXE to Repair System Files



Guide Overview

The purpose of this guide is to teach you how to use the System File Checker (SFC) to examine and repair corrupt operating system files.

In doing this, the SFC tool may replace some of your files that were updated by Windows Update. The only way to check this (and to update any of the files) is by visiting Windows Update and allowing it to check your system for updates and update as needed.

References

Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

Microsoft Windows XP - Repair overview (Link doesn't work as of 06 Aug 2008)

This link discusses the repair options: http://www.microsoft.com/windowsxp/using/s...rt/nostart.mspx

Instructions
  1. Locate your Windows XP installation CD. If you don't have one, you'll need to locate a directory on your system that's named"i386" (without the quotes). This directory may be on a hidden partition on your hard drive.

  2. Go to Start, then to Run, and type in "SFC.EXE /SCANNOW" (without the quotes - and with a space between the SFC.EXE and the /SCANNOW). The press Enter. (For VISTA, go to Start and type in the above information, then go to the top of the box and right click on SFC.EXE /SCANNOW and select "Run As Administrator")

  3. The program may (or it may not) ask you for your Windows XP installation CD - please insert it at the prompt. If it doesn't ask you for the CD this means that it wasn't necessary to replace any files.

  4. In the event the the system asks you for the CD, you must visit Windows Update immediately after the scan is completed (Please note that there won't be any confirmation dialog - the program will just exit without telling you anything).

  5. If this doesn't repair the problem with your system other troubleshooting procedures are required.
usasma
There have been some issues with running SFC.EXE /SCANNOW that this article doesn't address. They are:
1) The system won't accept the original installation disk because it doesn't have Service Pack 2 on it.
2) You don't have a Windows installation CD - only a restore CD from the manufacturer.

Here's how to deal with them:
__________________________________________________________________________

To fix the SP2 issue, you'll have to "slipstream" SP2 along with your installation CD. Rather than going through all the gory details here, just visit this link: http://www.winsupersite.com/showcase/windo..._slipstream.asp It provides a detailed explanation of how to slipstream SP2 along with your Windows installation CD.
__________________________________________________________________________

To fix the problem when you only have a restore CD you'll have to search for a folder on your hard drive (or on the restore CD) that's named "i386" (without the quotes). Once you find that, copy it to your hard drive at the root (C:\i386). Make sure that the directory is located at the root of your C: drive (C:\i386) - if not, then you'll need to change the path to the proper entry in the registry edit.

Then perform this registry edit to point SFC.EXE at it:

So, the first step is to backup your registry. The easy way to do this is to set a System Restore point ( http://www.microsoft.com/windowsxp/using/h...temrestore.mspx )

Next, go to Start...Run...and type in "regedit.exe" (without the quotes) and press enter. You'll see a folder-like view on the left, and entries on the right.

Navigate down the folder view on the left to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Setup Just click on the + sign to expand the view of the next level - so, to start, you'll click on the + next to HKEY_LOCAL_MACHINE and look for the SOFTWARE entry.

Then you'll click on the + next to SOFTWARE and look for Microsoft, and so on until you get to the Setup key. Then just click once on the Setup key.

Look in the right hand pane and double click on the entry that says "SourcePath".
In the box that pops up, type in "C:\" (without the quotes) and press Enter. Then close regedit and reboot your computer. SFC.EXE /SCANNOW should now run without problems for you.
___________________________________________________________________________
If you're unable to find the i386 folder, it may be that it's on a hidden partition on your hard drive or that the restore CD has been created in a different way and you can't view the directories.

If so, there's a couple of more things to try (please post your question in the forums) or you can look to see if your system has a repair or a non-destructive recovery option. This option will leave your programs and data intact while replacing all of the Windows files. This is also the next step if SFC.EXE /SCANNOW doesn't fix the problem.
lucas
I followe this instructions:
Next, go to Start...Run...and type in "regedit.exe" (without the quotes) and press enter. You'll see a folder-like view on the left, and entries on the right.

Navigate down the folder view on the left to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Setup Just click on the + sign to expand the view of the next level - so, to start, you'll click on the + next to HKEY_LOCAL_MACHINE and look for the SOFTWARE entry.

Then you'll click on the + next to SOFTWARE and look for Microsoft, and so on until you get to the Setup key. Then just click once on the Setup key.

Look in the right hand pane and double click on the entry that says "SourcePath".
In the box that pops up, type in "C:\" (without the quotes) and press Enter. Then close regedit and reboot your computer. SFC.EXE /SCANNOW should now run without problems for you.

BUT IT DID NOT FIX THE PROBLEM. IS THERE ANYTHING ELSE I CAN DO ?
usasma
Hi Lucas!

This is the first time that I've looked back at my mini-guide on using SFC.EXE and just noticed your post from Oct 7.

My apologies for not seeing this sooner, but the mini-guide forum isn't routinely monitored. If you're still experiencing problems, please post your problem at: http://www.bleepingcomputer.com/forums/ind...hp?showforum=56

- John
usasma
SFC.EXE uses the C:\Windows\system32\dllcache folder to replace changed files. It also uses a log file that I haven't been able to locate (although there should be entries in the Event Viewer that describes each change). EDIT: Here's how to analyze the logfiles in Vista: http://support.microsoft.com/kb/928228

There's (according to Microsoft) approximately 2,700 files that are protected. On my XP installation there's 2,511 files in the dllcache folder (so I'm missing almost 200). (see Post #8 for the list for SP3 - 3588 files).

Previously I've been of the opinion that explorer.exe wasn't protected - this ISN'T the case. It is protected.

SFC.EXE also protects the drivers contained in the drivers.cab file - but it should do this silently - but I'll need to do more research on it.

Optimizing Windows File Protection Service: http://support.microsoft.com/kb/229656
dirtfarmer
but i have a question what happen when you what to use sfc /scannow, and go to registry to change seting there so you do not need the xp cd any more

but find out on how to do it, ther is no SourcePath lisyted in registy


i have use sfc /scannow for a long time, with a home xp cd before sp1,, but i got a new compter with xp home sp2 cd,, and SourcePath is not there
david28
Hi, just thought I would mention this is a very good tutorial on how to use SFC. Well done usasma!

PS: I might also add that if you type in "How to use SFC" in Google, it is the second result!

Regards,
David.
usasma
Just a bit more info. I found out from Windows Internals, 4th Edition that the sfcfiles.dll file has the list of files that SFC.EXE scans for (you can view it with the Strings utility from SysInternals - but will have to pipe it to a text file because the output quickly overflows the available buffers in cmd.exe).

In my slightly customized Virtual Machine with SP3 installed, the list of files totals 3585 (changed from Post #5). This is after subtracting all the duplicates (about 4 for each file) and the "gibberish" that I didn't understand. So, it's safe to say that SFC.EXE scans at least 3585 files when it's working. Most of the files are .dll's, and most are located in the System32 sub-directory - but there's a lot that don't fit this rule.

BTW - this file doesn't seem to exist in Vista - so it'll take some more research on my part to figure out where it is now. sad.gif
hifrmny
QUOTE
There's (according to Microsoft) approximately 2,700 files that are protected. On my XP installation there's 2,511 files in the dllcache folder (so I'm missing almost 200). (see Post #8 for the list for SP3 - 3588 files).


I run XP Pro sp2 and in my dllcache folder, there are 2953 files. That's quite a bit above the 2700 you stated. I wonder why I have so many extras...
garmanma
QUOTE
I run XP Pro sp2 and in my dllcache folder, there are 2953 files. That's quite a bit above the 2700 you stated. I wonder why I have so many extras...

It's been a year since that statement. With updates and SP3 it's now more

QUOTE
with SP3 installed, the list of files totals 3585
Billy O'Neal
Hello, all smile.gif

If you run Windows XP SFC and it asks for your "Service Pack 3 Disk", you can extract the service pack 3 files as follows:

Download the standalone windows XP SP3 package from here:
http://www.microsoft.com/downloads/details...;displaylang=en
and save it to your desktop.

Then extract the files from the package by going to Start -> Run and entering:
CODE
"%userprofile%\Desktop\WindowsXP-KB936929-SP3-x86-ENU.exe" -x:C:\xpsp3

This will place the service pack 3 updates to the i386 folder into your C drive under the folder "xpsp3".

You should then be able to point SFC at this folder for the files it can't find from your windows disk or i386 folder.

Hope that helps,
Billy3
cmstormer
QUOTE(usasma @ Oct 5 2006, 08:14 AM) *
There have been some issues with running SFC.EXE /SCANNOW that this article doesn't address. They are:
1) The system won't accept the original installation disk because it doesn't have Service Pack 2 on it.
2) You don't have a Windows installation CD - only a restore CD from the manufacturer.

Here's how to deal with them:
__________________________________________________________________________

To fix the SP2 issue, you'll have to "slipstream" SP2 along with your installation CD. Rather than going through all the gory details here, just visit this link: http://www.winsupersite.com/showcase/windo..._slipstream.asp It provides a detailed explanation of how to slipstream SP2 along with your Windows installation CD.
__________________________________________________________________________

To fix the problem when you only have a restore CD you'll have to search for a folder on your hard drive (or on the restore CD) that's named "i386" (without the quotes). Once you find that, copy it to your hard drive at the root (C:\i386). Make sure that the directory is located at the root of your C: drive (C:\i386) - if not, then you'll need to change the path to the proper entry in the registry edit.

Then perform this registry edit to point SFC.EXE at it:

So, the first step is to backup your registry. The easy way to do this is to set a System Restore point ( http://www.microsoft.com/windowsxp/using/h...temrestore.mspx )

Next, go to Start...Run...and type in "regedit.exe" (without the quotes) and press enter. You'll see a folder-like view on the left, and entries on the right.

Navigate down the folder view on the left to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Setup Just click on the + sign to expand the view of the next level - so, to start, you'll click on the + next to HKEY_LOCAL_MACHINE and look for the SOFTWARE entry.

Then you'll click on the + next to SOFTWARE and look for Microsoft, and so on until you get to the Setup key. Then just click once on the Setup key.

Look in the right hand pane and double click on the entry that says "SourcePath".
In the box that pops up, type in "C:\" (without the quotes) and press Enter. Then close regedit and reboot your computer. SFC.EXE /SCANNOW should now run without problems for you.
___________________________________________________________________________
If you're unable to find the i386 folder, it may be that it's on a hidden partition on your hard drive or that the restore CD has been created in a different way and you can't view the directories.

If so, there's a couple of more things to try (please post your question in the forums) or you can look to see if your system has a repair or a non-destructive recovery option. This option will leave your programs and data intact while replacing all of the Windows files. This is also the next step if SFC.EXE /SCANNOW doesn't fix the problem.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.