首页 > 系统相关 >Using DISM to Check and Repair Windows Image

Using DISM to Check and Repair Windows Image

时间:2024-09-26 20:45:29浏览次数:8  
标签:files Repair Windows Image Component command image DISM

You can use the SFC (System File Checker) and DISM (Deployment Image Servicing and Management) commands to check and repair the integrity of system files and Component Store of your Windows (Windows Server) image. These tools can be extremely useful if your Windows is unstable, won’t boot, errors appear when you try to run built-in apps or services, after a virus infection, etc.

In this article, we’ll take a look at how to use the SFC /ScanNowDISM /Online /Cleanup-Image /RestoreHealth, or Repair-WindowsImage -Online -RestoreHealth commands to repair image and system files on Windows 10/11 and Windows Server 2022/2019/2016.

SFC /ScanNow: Using System File Checker to Repair Windows System Files

It is recommended to use the DISM command to restore Windows after you have checked the integrity of your system files using the SFC tool. The sfc /scannow command scans protected system files and if they are missing or corrupted it tries to restore their original copies versions to the Windows Component Store (C:\Windows\WinSxS folder).

The SFC tool writes all its activities to the %windir%\logs\cbs\cbs.log . All SFC entries in the CBS.log file are tagged with [SR]. To select only SFC-related entries from the log, run the command:

findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >"%userprofile%\Desktop\sfc.txt"

If sfc /scannow command returns the error “Windows Resource Protection found corrupt files but was unable to fix some of them“, it is likely that the tool could not get the necessary files from the Windows Component Store (see the image below).

In this case, you can try to repair the Component Store of your Windows image using the DISM.exe command.

The DISM (Deployment Image Servicing and Management) tool is available in all versions of Windows starting from Vista.  

After repairing the Windows image, you can try using SFC to restore your system files.

Check Windows Component Store Health Using DISM

The DISM /Cleanup-Image /CheckHealth switch is used to scan the Windows image for errors and fix them. DISM commands must be run from the elevated command prompt.

Run the following command to check if there are any flags of corruption in the Windows image Component Store (not applicable for Windows 7/Server 2008R2). This command checks the CBS flag set by one of the system maintenance processes.

DISM /Online /Cleanup-Image /CheckHealth

This command doesn’t perform a full scan of the Component Store. The command only checks if your Windows image is flagged as corrupted and if it is possible to fix it. No changes are made to the image.

In this example, the command has returned that the Windows 10 image has no corruptions:

No component store corruption detected.
The operation completed successfully.

To run a full scan of the Windows Component Store health, run the command:

DISM /Online /Cleanup-Image /ScanHealth

The command to check the Windows image can take quite a long time (10-30 minutes). And will return one of three results:

  • No component store corruption detected – DISM found no errors in the component store;
  • The component store is repairable – DISM has encountered errors in the Component Store and can fix them;
  • The component store is not repairable – DISM cannot fix the Windows Component Store (try using a newer version of DISM or you will have to restore a Windows image from a backup, reset or completely reinstall your Windows instance)

 To use DISM /ScanHealth switch on Windowds 7 and Windows Server 2008, you have to install the KB2966583 update. Otherwise, you will see the message: “Error 87. The ScanHealth option is not recognized in this context”.

In some cases, the DISM /ScanHealth returns the following errors:

  • DISM Error 1726 – “The remote procedure call failed”;
  • DISM Error 1910 – “The object exporter specified was not found”.

It definitely means that your Windows image is corrupted and needs to be repaired.

Repair Windows Image Using DISM /RestoreHealth

To fix corruption in the Windows image Component Store, you must use the RestoreHealth option of the DISM command. This option will allow you to fix errors found in the Windows image, and automatically download and replace files of damaged or missing components with original versions of files from Windows Update (your computer must have direct Internet access). Run the command:

DISM /Online /Cleanup-Image /RestoreHealth

In Windows 7/2008 R2, this command looks different:
DISM.exe /Online /Cleanup-Image /ScanHealth  

The process of scanning and repairing the Component Store may take quite a long time (30 minutes or more). DISM will automatically download and replace the files of corrupted or missing components with original file versions from Windows Update servers.

If the repair has been successful, the following message will appear:

The restore operation completed successfully

In all of these cases, you can use alternative ways to get the source Component Store files. It can be:

  • Installation disk/USB flash drive/ISO image;
  • Mounted wim/esd file;
  • Folder \sources\SxS from the installation disk;
  • The install.wim (esd) file with the Windows installation image.

You can specify a WIM or an ESD file with the original Windows installation image to be used as a source to repair the system files. Suppose, you have an installation Windows 11 ISO mounted to the virtual drive D:.

Note. To repair the corrupted files in the Component Store from the local source, the Windows build and edition in the WIM/ESD image must match those of your system.

Check which version of Windows is installed on your computer using the following PowerShell command:

Get-ComputerInfo |select WindowsProductName,WindowsEditionId,WindowsVersion, OSDisplayVersion

powershell: get current windows edition and version

List the available Windows editions in the installation wim image:

Get-WindowsImage -ImagePath "D:\sources\install.wim"

In our case, the Windows 11 Pro image in the install.wim file has ImageIndex = 6.

powershell: get-windowsimage index number

To repair the Component Store from a local WIM/ESD file using the local source files (without using Windows Update online services), run the following command (remember to specify the Windows version index in the image file):

DISM /online /cleanup-image /restorehealth /source:WIM:D:\sources\install.wim:6 /limitaccess
or:
DISM /online /cleanup-image /restorehealth /source:ESD:D:\sources\install.esd:6 /limitaccess

dism /clenup-image /restorehealth command in windows 11

The following errors can appear when running the DISM /RestoreHealth command:

 

  • Error: 50: DISM does not support servicing Windows PE with the /Online option – this means your DISM thinks you are using a WinPE image. To fix this, remove the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MiniNT;
  • DISM Error 87: make sure the DISM command is written correctly, and make sure you are using the DISM version for your Windows version (usually when booting in WinPE/ WinRE).

 

You can find the DISM log of scanning and repair of the system files here: C:\Windows\Logs\CBS.log.

After the component store has been repaired, you can run the system file checker tool (sfc /scannow). It is likely that it will be able to restore the damaged or missing system files (Windows Resource Protection found corrupt files and successfully repaired them).

tool sfc /scannow - Windows Resource Protection found corrupt files and successfully repaired them

If the SFC.exe doesn’t detect any damage to the system files, a message will appear

Windows Resource Protection did not find any integrity violations.

Repair-WindowsImage: Repairing Windows Image Component Store with PowerShell

The version of PowerShell in Windows 10/11 and Windows Server 2016/2019/2022 has a cmdlet similar to the DISM commands discussed above. To scan the Windows component store and find any corruptions, run this command:

Repair-WindowsImage -Online –ScanHealth

Repair-WindowsImage -Online –ScanHealth powershell

If no errors are found in the Component Store, the following message appears:

ImageHealth State: Healthy

To repair Windows Component Store files, run:

Repair-WindowsImage -Online -RestoreHealth

If you don’t have direct Internet access, this command may hang during the image repairing process. You can restore the system components from the local Windows image file (install.wim/install.esd) copied from the Windows 10 installation ISO image. Here you also need to specify the Windows version index in the WIM file as the recovery source:

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

Use DISM Offline to Repair Windows Image

If Windows doesn’t boot correctly, you can use DISM to check and repair system files of your Windows image offline.

  1. Boot your device from the Windows installation image (you can use the Media Creation Tool to create a bootable Windows USB stick) and press Shift + F10 on the initial Windows install screen;
  2. To check the drive letters assigned in WinPE, run the command diskpart -> list vol (in my example, the drive letter C:\ is assigned to the disk, on which Windows is installed, and I will use it in the next commands); diskpart - get assigned drive letters
  3. Check the system files and repair the corrupted ones with the command: sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
    sfc /scannow offline: offbootdir offwindir
  4. To repair the offline Windows image, use the following command (I am using a WIM file with the Windows 10 installation image from which the computer is booted as a source to restore my offline Windows image):
    Dism /image:C:\ /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim
    dism /cleanup-image - restore offline windows 10 image from source wim file
  5. If there is not enough free space on the target disk, you will need a separate drive, for example, F:\, on which you will create an empty folder mkdir F:\scratch . Perform a repair of the component store using the scratch dir with the command: Dism /image:C:\ /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim /ScratchDir:F:\scratch
Tip. Here are some useful DISM parameters an administrator must know:

《From: Using DISM to Check and Repair Windows Image | Windows OS Hub (woshub.com)

标签:files,Repair,Windows,Image,Component,command,image,DISM
From: https://www.cnblogs.com/rusking/p/18434308

相关文章

  • AttributeError: ‘ImageDraw‘ object has no attribute ‘textsize‘
    在进行画框的时候发现代码报错了,查询原因后发现我的pillow版本删除了该方法有两种处理办法:1、就是降低版本2、就是根据新版本修改代码,我这里主要来介绍一下新版本如何修改代码,把textsize改为textbbox首先先了解一下原先这个textsize方法的作用查看官方文档给的示例 from......
  • Windows中Mysql忘记密码如何重置密码(密码一定要存备份o(╥﹏╥)o)
    文章目录在Windows系统中,如果忘记了MySQL的root密码,你可能是这样的o(╥﹏╥)o,找了两节课半终于重置好了!!可以通过以下步骤来重置密码:停止MySQL服务:打开命令提示符(CMD)并输入以下命令来停止MySQL服务:netstopmysql启动MySQL并以--skip-grant-tables......
  • Windows 使用 tree 命令
    Windows使用tree命令基本语法tree[drive:][path][/F][/A]参数说明[drive:][path]:指定要显示树结构的驱动器和目录。如果未指定路径,则使用当前目录。/F:显示每个文件夹中的文件名。/A:使用ASCII字符而不是扩展字符来显示链接子目录的线条。示例显示当前目录的树结......
  • Windows11电脑弹窗“找不到ole32.dll”文件该怎么办?Win11电脑系统提示“缺少ole32.dll
    在使用Windows11电脑的过程中,突然弹窗提示“找不到ole32.dll”文件,这可如何是好?别慌,这种情况通常是由于系统文件缺失或损坏导致的。下面将为您细致地介绍解决这一问题的有效办法,帮助您消除困扰。本篇将为大家带来Windows11电脑弹窗“找不到ole32.dll”文件该怎么办的内容,感兴趣......
  • 遇到stdole.dll强签名无效?Windows用户必看:如何安全处理stdole.dll的强签名验证问题
    遇到stdole.dll强签名无效的问题时,Windows用户需要谨慎处理以确保系统的稳定性和安全性。以下是一些安全处理stdole.dll强签名验证问题的步骤和建议:一、了解stdole.dll首先,了解stdole.dll是一个关键的系统文件,它主要负责OLE(对象链接与嵌入)技术的一些基础功能。在Windows操作......
  • Windows如何本地部署llamafile并运行千问7b大模型无需安装运行环境或依赖库
    文章目录前言1.下载llamafile2.下载大语言模型3.运行大语言模型4.安装Cpolar工具5.配置远程访问地址6.远程访问对话界面7.固定远程访问地址前言本文主要介绍在Windows系统电脑如何利用llamafile结合cpolar内网穿透工具,实现随时随地远程访问本地大语言模型的......
  • 通过理解 Windows rollback attack 的基础架构,用户和管理员可以更有效地保护系统免受
    “Windowsrollbackattack”是一种针对Windows操作系统的攻击手法,具体涉及利用系统恢复或回滚功能来执行恶意行为。以下是关于这种攻击的简要说明:什么是WindowsRollbackAttack定义:这种攻击利用Windows系统的恢复功能(例如,系统还原点或回滚机制)来恢复到之前的状态,从而可......
  • Windows Server 2019 Web服务器之IIS的安装与基本配置
    准备工作:选择一台服务器作为WEB-IIS服务器在WindowsServer2019系统中,IIS角色是可选组件,默认情况下是没有安装的。1.在windows服务器中安装IIS1)打开【服务器管理器】,单击【添加角色和功能】。2)默认选择【基于角色或基于功能的安装】,点击【下一步】。3)默认选项,继续下一步。......
  • DISM API(Deployment Image Servicing and Management API)是一个用于服务和管理 Window
    DISMAPI参考|MicrosoftLearn基本DISMAPI示例|MicrosoftLearn部署映像服务和管理(DISM)API|MicrosoftLearnDISMAPI(DeploymentImageServicingandManagementAPI)是一个用于服务和管理Windows映像文件的接口,特别用于处理Windows操作系统的安装、维护和更......
  • 2024年模式识别与图像分析国际学术会议(PRIA 2024) 2024 International Conference on P
    文章目录一、会议详情二、重要信息三、大会介绍四、出席嘉宾五、征稿主题六、咨询一、会议详情二、重要信息大会官网:https://ais.cn/u/vEbMBz提交检索:EICompendex、IEEEXplore、Scopus2024年10月18-20日南京三、大会介绍2024年模式识别与图像分析国际学术会......