Online recovery for Windows 7. Restoring damaged Windows system files using SFC and DISM commands

Restoring a working system configuration is an interesting, but very voluminous topic. Even the seemingly simple question of how to recover damaged Windows 7 files has several solutions that can be implemented in different ways.

The most convenient and easiest method for users is to use the system restore function, which allows you to roll back the configuration to the last working state. But what if this useful feature is disabled or checkpoints are deleted?

The system is booting

If damaged files do not prevent the system from starting, you can try to restore its functionality using the Windows command line.

If the system files are ok, you will see a message like this:

If the utility detected Windows errors and was able to fix them, the following notification will appear on the screen:

In any case, the system files have been restored. Now you can restart your computer and enable the function of creating restore points, which will greatly simplify the process of rolling back the system to a working state.

Sometimes users encounter the fact that in normal mode, damaged files are not restored using the sfc.exe utility. If this problem occurs, you need to restart your computer, start the system in safe mode with command line support, and try running the sfc.exe utility again.

System won't boot

If the computer refuses to boot, you will have to use the recovery environment to restore functionality. You can launch it in two ways:

  1. By pressing the F8 key when turning on the computer.
  2. Using the installation disk or flash drive.

The first option works if a boot partition was created when installing Windows and partitioning the disk. If you don't know what this is, still try pressing the F8 key several times when you start your computer. A window with additional download options will appear on the screen, in which you need to select the “Troubleshooting” option.


So, you are at the command prompt using the first method to launch the recovery environment. In it you need to enter the command sfc /scannow /offbootdir=D:\ /offwindir=D:\windows.

After a short wait, a message will appear on the screen indicating that the files were successfully restored.

Attention! In the body of the command, instead of the letter “D”, you indicate the designation of your disk on which the operating system is recorded.

If it suddenly happens that you cannot remember the letter of the partition with Windows installed, try the following options for viewing it:


Another way to find out the letter is to use the Diskpart utility.


By the size of the partition you can easily determine which one the system is installed on.

Using bootable media

If you can’t get into the recovery environment using the F8 key, try using an installation disk or flash drive. To do this, you need to configure the BIOS by setting the boot priority.


Enter the command sfc /scannow /offbootdir=D:\ /offwindir=D:\windows and wait until the system file recovery process completes.

Windows 8

Users who want to recover damaged files on Windows 8 or 8.1 can use another method that allows them to restore functionality to the system file backup storage and replace damaged data.

Windows PowerShell

If the system starts, try opening the PowerShell utility through the Start window or Start menu. You need to run it with administrator rights.

In the window that appears, enter the command “Online /Cleanup-Image /RestoreHealth”. If the backup storage is intact or can be restored, you will see a message like this:

After the reboot, you need to launch the command line using one of the methods described above and try to restore files using the “Sfc” utility.

Using a Windows distribution

If Windows PowerShell cannot restore the backup file storage itself, you can try using a disk image with the Windows 8 distribution.


If the first edition doesn't work, try another version. After restarting the computer, try again using the command line to scan the disk and restore files.

Hello, friends! Restoring system files in Windows 7 or Windows 8/8.1 is an interesting topic. Especially if the operating system starts to fail, but we don’t have a recovery image and we forgot to turn on system protection so that recovery points can be created. In this case, we will not be able to restore the system from the image, we will not be able to roll back Windows to the created restore point, and we are also too lazy to reinstall the system, since this will take the whole day. And right here we have another chance to return Windows to normal - try to restore system files. In this article I will try to fully cover the topic so that we can revive our computer in any situation.

In the command line that opens, write:

sfc /scannow

We are waiting a little...

If your system is fine, you will see the following image.

If your Windows was broken, you will see the following.

System files were successfully restored. We reboot and immediately turn on system protection to create restore points so that next time we can simply roll back the state of the computer to a couple of days ago and that’s it.

It happens that when scanning the system, the sfc.exe utility found damaged files, but could not fix them. In this case, I would restore system files in Safe Mode. If in safe mode the same thing, read the last of this article.

If you are unable to enter the recovery environment using the F8 key, you will need to boot from the installation (bootable) flash drive or disk. How to boot from a flash drive - . You can boot from disk in the same way. Only in this case you need to put the DVD-RW (optical disc reader) first in the boot priority.

I like to boot from removable media using the boot menu. On ASUS motherboards it is usually also called by the key F8.

After booting from a flash drive or disk, I saw the following picture. I choose Windows Setup— Installation of Windows.

We choose the one that does not turn on for us. And here CAREFULLY! We remember the letter that the recovery environment assigned to your system (in the Folder column). I have this D.

Enter the command:

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

You can go to the disk and make sure what and where.

  1. Using the utility DISKPART

On the command line enter:

diskpart— call the utility for working with disks.

list disk— look through the list of disks.

select disk— I select the hard drive I need.

For Windows 8/8.1

If the sfc utility was unable to restore damaged system files, then you need to try to restore the storage of these system files. The place where copies of working system files should be located. As I understand it, it is located at C:\Windows\WinSxS. That is, we must first fix the file storage, and then use the “SFC / Scannow” command to restore Windows system files.

Recovering storage using Windows Update

  1. Launch Windows PowerShell with administrator rights. To do this, open the Start menu or home screen and click on the “Search” icon. In the search box we write “PowerShell”. Right-click on “Windows PowerShell” and select “Run as administrator” or “Run as administrator”.
  2. In the window that opens we write

Dism /Online /Cleanup-Image /RestoreHealth

and wait. If the storage is intact or it was restored using Windows Update, you will see the following picture.

If Image Health State: Healthy - everything is fine. Reboot the computer and try SFC /SCANNOW again.

Restoring storage using an image

If we have problems with Windows Update, then this method will do.

  1. Download the original Windows 8/8.1 image of the same bit size as your system. How to find out the bit depth of the installed system - .
  2. Connect or mount the downloaded image. Right-click on the image and select “Connect” or “Mount”.

    In the command line with administrator rights, we look at what editions there are in the image with the command

I have 2 editions in my image. It’s hard to understand which one I need based on these distinctive signs. Let's use the first one. If it doesn’t work, the second one.

  1. Launch Windows PowerShell with administrator rights and issue the command

Repair-WindowsImage -Online -RestoreHealth -Source F:\sources\install.wim:1

where F is the drive letter to which we connected the image, 1 is the Windows edition number in the image.

Recovering system files manually

If using the sfc utility it was not possible to recover damaged files, you need to try to do it manually. In this case, you need to additionally run the command

findstr /c: %windir%\Logs\CBS\CBS.log > %userprofile%\Desktop\sfcdetails.txt

Findstr /c: %Windir%\Logs\CBS\cbs.log>sfcdetails.txt

and carefully study the file sfcdetails.txt on your desktop or %windir%\Logs\CBS\.

It should be something similar to the picture below.

After the name of the damaged file is known (Accessibility.dll), we look for it on another computer with the same system as yours. If this is not an option, then I would download the original Windows image and install it on the virtual machine. I found the file I needed and copied it to a bootable or installation flash drive. Then, from this installation flash drive, I booted into the recovery environment and launched the command line. From the command line I would open notepad. I opened the menu File > Open - and now I have an almost full-fledged explorer. We copy and replace the working file from the flash drive, reboot and everything should work.

If the option of installing a virtual machine does not suit you, then you can include the install.wim file in the folder. Then go to this folder and copy the necessary files.

  1. Let's create a folder. For example, “Win8.1Pro” in the root of drive D.
  2. Copy the install.wim file to the root of drive D.

    Mount the install.wim file into the created folder.

Go to the created folder and copy the necessary files.

Disable the image

Dism /Unmount-Wim /MountDir:D:\Win8.1Pro /Discard

Conclusion

This is how I will try to restore system files in Windows 7/8/8.1. Write questions and suggestions in the comments. Thank you for sharing the article on in social networks. All the best!

Best regards, Anton Dyachenko

The problem of unstable operation of Windows 7 is often associated with corruption or deletion of system files, for example, after reinstalling or installing an infected program. This is not the most difficult problem - there are many ways to restore data using standard OS tools or manually. We will consider the simplest and most effective options below.

Rollback to last stable state

By default, in all Windows, protection is active for system partitions. It is responsible for creating special checkpoints containing configuration information and system files of the environment before modifying it - installing applications, drivers and updates. Moreover, restore points are created without such a reason by the system at a certain frequency or by the user himself.

If problems began to appear relatively recently, and you remember the approximate date of their appearance, then the best solution is to roll back the OS to a point when no failures were observed during the operation of the OS.

In a production environment this is very easy to do:

All that remains is to reboot, after which the damaged system files will be replaced with previous working versions.

If Windows won't boot

Even if the damage to system data is so serious that the OS cannot boot on its own, you can use restore points:


The corresponding control point selection utility will launch, which you need to work with in the manner described earlier.

If pressing F8 does not open the boot options window, then you will only be able to get into the recovery environment if you use the boot/installation disk.

Using the standard SFC utility

This application checks and repairs basic OS system files. It can also be run on the command line from a boot disk, from the boot options window after pressing F8, and from a running system. The last option is the simplest:


Once the operation is complete, SFC will notify you of the results - the corrupted data should be detected and corrected.

Recovering data manually

Sometimes the methods described above cannot fix the problem. For example, when updating DirectX from distributions that come with various applications, DLLs are often lost. Therefore, always try to update DirectX from the office. Microsoft website, and if trouble has already happened, then if a new version is available, all DLLs will be updated automatically after installing a fresh component package from the website http://www.microsoft.com/ru-ru/download/confirmation.aspx?id=35.

If there is no new version on the specified page, then any DLL from another source can be transferred to your system yourself. Libraries are stored in the following directories:

  • for Windows 7×32 - in the folder C:\Windows\System32;
  • for Windows 7x64 - in the C:\Windows\SysWOW64 directory.

If, when you launch an application, a window appears informing you that a DLL is missing, and the installer from the Microsoft website reports its presence on your system latest version libraries and does not update components, you can simply use the search engine. Find DLLs on the Internet and move them to the specified folders.

Not only DLLs, but also any damaged system files can be extracted from the Windows 7 installation distribution. To do this, you just need to know which files are damaged. Often the OS itself informs the user about the absence of a DLL or about an application error, for example, Explorer.exe. You can get the information yourself.

Let's find out what system information is faulty

To do this, you will again need the command line; we have already described how to open it. Write the following command here:

indstr /N:"" %windir%\Logs\CBS\CBS.log >"%userprofile%\Desktop\sfcdetails.txt", where N is the drive letter.

Press Enter, after which sfcdetails.txt will be created on the desktop, which you need to open and carefully review. Its content will be similar to the image below.

Here we see that the Accessibility.dll library is damaged. It is this that you will need to find on the Internet or extract it yourself from the existing Windows 7 distribution to carry out the recovery.

Extracting OS components from the distribution

In addition to the installation disk, you will need a small free 7-zip application. With its help, we will work with the install.wim image located in the sources directory. The order is as follows:


All that remains is to copy them to the desired folder or flash drive. You can replace damaged data with them using installation/bootable media or LiveCD.

The problem of treating damaged Windows 7 files is solved in several ways. The simplest option is to roll back the system configuration to one of the previous working states. However, this is not always feasible, since the corresponding function can be disabled by the user, and control points can be deleted. In addition, recovery will differ depending on whether the corrupted data allows the system to boot or not.

Using the Command Line

If the system files have not been damaged so much as to prevent the system from booting, you can try to restore it to full functionality by entering the command line in the standard way:

  1. Press Win and R at the same time, and in the Run window, write down the cmd.exe command. You can also get to the line through the start menu.
  2. Enter sfc /scannow and the scan will start.

When the Run window opens, make sure that there is a line under the input field notifying the user that the command is running with administrator rights.

This line may not appear due to User Account Control being enabled.

Then, after running the sfc /scannow command, you will only be able to see a black window for a moment, which will immediately disappear and the scan will not be carried out.

To avoid this, you need to either disable User Account Control in Windows, or run the application as an administrator by selecting the appropriate item in the context menu when right-clicking on the command line program icon.

If the program does not detect an error, a corresponding message will be displayed on the screen upon completion of the check. The utility will also notify you about the detection of various types of errors, which it will try to automatically correct. Next, you only need to reboot the device, after which the problems when accessing the system should disappear.

Sometimes the utility cannot cope with fixing damaged important files in normal mode. You need to do the following:


The application will most likely be able to solve the problem and the system files will be fixed.

If you can't log into Windows

Damage to significant files may be such that it will be impossible to log into the OS in the usual way. In this case, use the standard Windows 7 recovery environment, which can be accessed in the manner already described via F8 or via an installation disk or boot disk. You can create the latter in advance using the OS itself.

A boot disk may be needed in case of serious damage to the file system, when without it it is impossible to boot not only the system, but also the environment in which the OS can be restored. The emergency storage is used as follows:

  1. After inserting the disk or bootable USB flash drive, go to the boot menu of the device. For laptops, this is usually the F12 key, which must be pressed immediately after turning on the power. On desktop computers, these may be buttons F8-12, etc., depending on the motherboard.
  2. In the boot menu window, select the device from which the subsequent boot should be made - an optical disk or a flash drive. If this function is not available for your device, you will have to change the appropriate BIOS settings.
  3. After selecting your language, click “Next” in the next window.
  4. When using the installation disk, in the Windows installation window, you need to click on the link at the bottom of the window.
  5. In the options menu, highlight the first option and select your operating system. Surely you only have one installed and you can only select Windows 7 from the list, click “Next”.
  6. In the tool menu that opens, to restore the OS, select the bottom line to open the command line window.
  7. Here you will need to run the same application, but the command will be longer: sfc /scannow /offbootdir=N:\ /offwindir=D:\windows, where N is the disk partition on which Windows system files are stored.

The program will scan the system and, if necessary, replace all damaged files, after which the system will operate normally.

If you are not using a boot disk, then in the boot options window that opens after pressing F8 when turning on the power, you will need to select the first troubleshooting item. After this, you will be taken to the options window discussed above.

How to find out the letter of the system partition if you have forgotten it

If you suddenly cannot remember the letter of the partition with Windows installed, you can find it directly from the command line. For this:

  1. In the command line, write the line notepad, the standard “Notepad” will open;
  2. In the menu at the top, select “File”, in the list, click on the “Open” command;
  3. In this way, you will be taken to the usual Explorer, where in “My Computer” you can see all your disks and partitions.

Partition letters can be found out even easier using one of the standard commands:

  1. At the command prompt, type Diskpart.
  2. After pressing Enter, write down the list disk command, the screen will show all the physical disks installed on the device, each of which will be assigned a number starting from zero.
  3. Use the select disk command with its serial number to select the desired drive. If there is only one physical disk, enter select disk 0;
  4. Next, write down detail disk - detailed information about the disk and all its partitions will be displayed.

As a result of some Windows 7 malfunctions and malware infections, there is a need to analyze the file integrity of the system. Also, files are often damaged due to improper shutdown of the PC and power surges. Therefore, every “Seven” user should be able to independently check and resuscitate system files on a computer with Windows 7.

File analysis method

The main tool for checking and analyzing their integrity in “Seven” is the “SFC.exe” application built into the OS, which can also restore defective files. Regular use of the command to perform the “sfc /scannow” scan will ensure the smooth operation of Windows 7. It is recommended to use it at least once every six months.

Analysis procedure

The built-in scan tool in Windows 7 runs as follows:

Note: Do not close the console until the procedure is complete. Upon completion, the results of the completed program will appear.

  1. Restart your computer;
  2. Ready. The system integrity check has been completed and the corrupted files have been fixed.

Sometimes it happens that an application cannot cope with fixing damaged files on its own. In such cases, it is recommended to perform analysis in safe mode, but even if this does not resolve the problem, you need to run: “findstr /c:” “%windir%\Logs\CBS\CBS.log >”%userprofile%\Desktop\sfc .txt".

After this, a “txt” file will appear on the Windows 7 desktop with a list of all files that the program is not able to resuscitate itself. The user needs to copy these files to himself from another computer, but with a working Windows 7, or from an external installation media with a distribution kit of the “Seven” modification that runs on the user’s PC.

Algorithm for restoring a damaged file manually

Now, knowing the exact name and location of the problematic file that the application could not fix automatically, you need to replace it. To this end, it is necessary to take the following sequential steps:


What if the SFC.exe application does not work at all?

It happens that the utility cannot even start. In such a situation, you should analyze the performance of the following applications:

  1. Remote Procedure Call Locator;
  2. Remote procedure call;
  3. Starting DCOM server processes.

If these programs are functioning normally, "SFC.exe" will start.

Also, the utility will not cope with its functions when the manual startup type of the recovery service is activated in the Windows Module Installer service.

Additional analysis methods via SFC

If you need, for example, to analyze the integrity of files on a remote OS or solve various other problems, then there are several of the following effective techniques:

  1. It is possible to carry out a check without a subsequent recovery process. To do this, using the algorithm of the instructions given above, you need to use the command “sfc /verifyonly”.
  2. If necessary, you can resuscitate only a specific file by typing in the console: “sfc /scanfile=Location”.
  3. In a situation where you need to analyze Windows installed on another logical partition of the hard drive, the command: “sfc /scannow /offwindir=Windows directory location” will help.

Conclusion

Some users, at their own discretion, modify files, change icons in Explorer, and the like. After the application works to analyze and correct the integrity of the OS, all adjustments made will be canceled and will again take the default form. Therefore, such computer owners will need to perform all their system modification operations again after the utility has completed its work.