19 June 2011

Repair System Files in Windows Using sfc scannow command



Sometimes due to loss of system files in windows operating system, the system does not work properly or gives you lot of errors of missing files. It crashes too often or some Windows programs do not work. In that case you have no alternative rather than to install windows again. But if you want to prevent the installation, then you can use the Windows System File Checker (sfc) to retrieve corrupt system files. sfc command checks and scan all your Windows important files and discover missing or overwritten files. Follow these steps:


Step 1

Go to Start Menu>cmd>Run as administrator and type sfc /scannow and press Enter. If you are using the Windows XP, enter sfc /scannow inside the Run dialog box.



Step 2

Now Windows begins scanning the system for missing system files. If Windows finds any missing or corrupted file, it will try to repair the file (during the scan, it may ask you for the Windows CD or DVD).


Step 3

For checking the corrupted system files without repairing them, you can use the sfc /verifyonly command instead of sfc /scannow.


more options for sfc command are:

sfc /scanonce will scan all system files once.
sfc /scanboot will scan all system files every time your PC is restarted.
sfc /revert will return the sfc command to its default operation.
sfc /purgecach will purge the Windows File Protection (WFP) file cache and then start scan the system files.
sfc /cachsize=x will set the size (in MB) of the Windows File Protection (WFP) file cach.

For those that they do not know what is a WFP file, a WFP or Windows File Protection file prevents other programs from replacing the Windows protected or important files.


Windows Resource Protection Could Not Start the Repair Service Error

If you got the error:

Windows Resource Protection Could Not Start the Repair Service 

then in the Start search box type "services" and hit the Enter key. Under the Services(Local), find "Windows Modules Installer" and make sure it is enabled and  its Startup type set to Manual. Again open the CMD window and try the sfc /scannow command.




Windows Resource Protection could not perform the requested operation Error

There are several reasons may cause to the Windows Resource Protection could not perform the requested operation error.


Some of them might be changes and modifications that we have made in our system registry before, or the Windows is not able to automatically repair corrupted system files. The best way to find the cause of error is to read the Windows CBS.log file. When we execute the sfc command, its log file will be saved in the C:\Windows\Logs\CBS\CBS.log path. In the windows Command Prompt, type the exact command below and hit the Enter key:


This command creates sfcdetails.txt file from the CBS.log file and places it on your desktop.



Go to your desktop and open the sfcdetails.txt file. Check the list of scanned files and try to find the system files that Windows is not able to fix automatically. Any corrupted file that you found in the list, you can replace it manually (Google search it).



Another method is to run the sfc command at the Windows Boot. Restart your system, when it tries to start (before the Windows screen log), press the F8 key for several times to enter the Windows Advance Option menu. From the menu select "Safe Mode with Command Prompt" and hit the Enter key. In the Windows Safe Mode's Command Prompt, type sfc /scannow, press the Enter and see if you face the same problem again or not. If again you got the same error, then you need to repair the Windows system file from CMD at Boot and use the command below:

sfc /scannow /offbootdir=c:\ /offwindir=d:\windows

Restart your system and change the boot order to the CD/DVD drive. Insert your Windows CD/DVD or System Recovery disk into the CD/DVD ROM and start your PC. In the Select Language window, hold the Shift key and press F10. The Windows Command Prompt will be opened.



But anything, you have to find your computer System Reserved and Windows drive letter as in the recovery environment they are not same as they are in the online mode. Enter diskpart in the CMD, hit the Enter key and then list volume.
 


As you can see, I used a dual boot OS, so my system has a System Reserved partition with drive letter "J". I have to assign this volume letter to the offbootdir and the offwindir will assigned to the Windows operating system.


Type exit, press Enter to exit from the diskpart and execute the command above. the original command is:


where the <drive> is the Windows drive volume letter. If your system does not have separate System Res, then drive letter for the offbootdir and offwindir will be the Windows operting system that you are trying to repair like:

sfc /scannow /offbootdir=d:\ /offwindir=d:\windows

Do not forget to execute "diskpart>list volume" first to check the OS volume letter in the offline mode, exit from the diskpart and then run sfc command.