了解如何使用 DISM 命令行工具來修復 Windows 11 PC 上的大多數問題。

DISM(部署映像服務和管理)是一個命令為管理員和專家開發的工具,用於掃描和修復 Windows 映像,包括 Windows 恢復環境、Windows 安裝程序和 Windows PE (WinPE)。它是 Windows 11 中的內置工具,可以檢查和修復受保護的系統文件和 Windows 映像的組件存儲。

如果您的 Windows 11 PC 無法正常工作,應用程序無法打開,您的文件已損壞、卡在藍屏等情況下,您可以運行 DISM 工具來修復這些問題。在大多數情況下,系統文件檢查器(SFC 掃描)工具可以通過丟失或損壞的系統文件來修復 Windows 安裝的各種問題。但是,如果 SFC 工具無法解決問題,您可以使用 DISM 修復 Windows 11 上的映像和系統文件。

即使您的系統無法啟動,您也可以通過一系列修復系統來自 Windows 恢復環境的 DISM 命令。在本指南中,我們將向您展示如何使用 DISM 命令來解決 Windows 11 中的各種問題。

運行 DISM 命令以恢復損壞的文件

DISM 首先掃描您的計算機是否損壞或丟失與不同 Windows 服務關聯的文件。之後,它將從 Microsoft 服務器下載所需的圖像和文件並替換損壞的文件。為此,您需要有效的互聯網連接。

要運行此工具,首先,您需要以管理權限啟動命令提示符。然後,依次鍵入以下命令,並為每個命令按 Enter:

ScanHealth:此開關會掃描系統的組件存儲中是否有損壞的文件並將記錄存儲在 C:\Windows\Logs\CBS\CBS.log。但是這個命令並不能解決問題。要掃描文件損壞,請輸入以下命令並按 Enter:

DISM/Online/Cleanup-image/Scanhealth

DISM 不區分大小寫,您可以隨意編寫(DISM、dism、暗淡等)。

CheckHealth:在第一個命令完成掃描後,輸入這個命令。 CheckHealth 參數通過檢查現有錯誤日誌來驗證系統文件中是否檢測到任何損壞。此命令還會讓您知道映像是否健康、可修復或不可修復:輸入以下命令檢查映像的健康狀況:

DISM/Online/Cleanup-Image/CheckHealth

檢查過程需要 10-15 分鐘才能完成。完成後,您將看到以下消息之一:

未檢測到組件存儲損壞-這意味著 DISM 掃描未在系統文件中發現任何損壞或錯誤,因此不需要運行下一個命令。 組件存儲是可修復的-這意味著已檢測到某些組件存儲損壞,可以使用/RestoreHealth 參數修復。 組件存儲不可修復-如果您遇到此問題,則以下 DISM 命令無法修復 Windows 組件存儲損壞。您將不得不嘗試其他一些故障排除方法來修復錯誤,例如從備份中恢復 Windows、重置或完全重新安裝 Windows。

RestoreHealth:最後一個參數修復損壞的文件並將損壞記錄存儲到 C:\Windows\Logs\CBS\CBS.log。要恢復系統映像的健康狀況,請輸入以下命令:

DISM/Online/Cleanup-Image/RestoreHealth

然後,等待該過程完成,這將需要 10-15 分鐘,具體取決於損壞情況。如果損壞的文件得到修復,您將看到“恢復操作成功完成。

在完成之前不要中斷該過程。該過程完成後,重新啟動您的 PC 並查看問題是否已解決。

如果您想查看日誌文件以獲取更詳細的 DISM 掃描和修復報告,請輸入文件資源管理器地址欄中的以下路徑並按 Enter:

C:\Windows\Logs\DISM\dism.log

C:\Windows\Logs\CBS\CBS.log

或者,您打開運行命令並鍵入以下命令之一以打開日誌報告:

%windir%/Logs/CBS/CBS.log

%windir%\Logs\DISM\dism.log

如果您看到“Windows 資源保護檢測到損壞的文件並成功恢復它們”。消息,這意味著 DISM 已找到並修復損壞的文件。然後您可以重新啟動您的 PC 並查看問題是否已解決。

使用 PowerShell 修復 Windows 映像

您還可以使用 Windows PowerShell 修復 Windows 組件存儲,因為 Windows 中的 PowerShell 版本11 和 DISM 命令有類似的 cmdlet。要使用 PowerShell 修復 Windows 映像,請執行以下步驟:

首先以管理權限啟動 PowerShell。在 Windows 搜索中搜索“PowerShell”並右鍵單擊頂部結果並選擇“以管理員身份運行”。

檢查 Windows 圖像:

鍵入以下命令並按 Enter 以檢查 Windows 組件存儲是否損壞:

Repair-WindowsImage-Online –CheckHealth

此命令可快速檢查系統映像中是否存在任何損壞,但無法修復任何問題。

如果您在掃描報告中看到“ImageHealthState:Healthy”,則表示在組件存儲中未發現任何錯誤。

掃描 Windows 圖像:

如果您看到’ImageHealthState’為’Repairable’,表示你需要運行下面的命令來掃描圖像:

Repair-WindowsImage-Online –ScanHealth

上面的命令沒有修復任何東西,它只會發現損壞和將詳細信息保存在日誌文件 (C:\Windows\Logs\DISM\dism.log) 中。

修復 Windows 映像:

掃描完成後,在提升的 PowerShell 窗口中鍵入以下命令並按 Enter:

Repair-WindowsImage-Online –RestoreHealth

此命令檢查損壞,如果遇到任何損壞,它將自動修復它。

如果你沒有互聯網,你可以使用’source’選項和’install.wim/install.esd’來恢復系統組件。您可以從本地 Windows 映像文件 (install.wim/install.esd) 脫機運行 DISM 命令。為此,請執行以下命令:

Repair-WindowsImage-Online-RestoreHealth-Source G:\sources\install.wim:6-LimitAccess

您需要在.esd 中指定 Windows 版本索引的位置/.wim 文件。

使用 install.esd/.wim 修復 Windows 映像映像脫機

如果您無法訪問 Internet 或 DISM 發現替換損壞文件的問題,您將需要使用可啟動安裝媒體或 Windows 11 ISO 文件提供另一個 Windows 映像。您可以使用可啟動安裝媒體或已安裝的 Windows 11 ISO 文件中的“install.wim”或“install.esd”文件離線運行 DISM。

創建 Windows 11 可啟動 USB 驅動器或安裝 Windows 11 ISO

首先,您需要使用媒體創建工具下載 Windows 11 的新副本。以下是創建可啟動 Windows USB 驅動器的方法:

轉到官方 Windows 11 下載頁面

a> 並單擊“創建 Windows 11 安裝媒體”部分下的“立即下載”按鈕。

然後,選擇一個目標文件夾並點擊“保存”。

之後,雙擊“MediaCreationToolW11.exe”工具運行安裝程序。如果您看到“用戶帳戶控制”提示,請單擊“是”。

之後,點擊“接受”按鈕接受許可條款。

如果您想繼續使用默認語言(英語(美國))和版本,請在下一個窗口中單擊“下一步”。如果您想更改語言和版本,請取消選中“為此電腦使用推薦選項”選項,然後從下拉菜單中選擇語言和版本。

接下來,選擇“USB 閃存驅動器”以創建 USB 安裝介質。或者,如果您想稍後將 ISO 刻錄到 DVD 或掛載映像,請選擇“ISO 文件”。

如果您選擇“ISO 文件”作為媒體選項,您可以將 Windows 11 ISO 文件保存在本地驅動器上。然後,雙擊下載的 ISO 文件掛載映像。

從驅動器列表中選擇 USB 閃存驅動器,然後單擊“下一步”。

這將創建一個可用於運行 DISM 工具的 Windows 安裝媒體。

使用 install.esd/wim 修復 Windows 11 恢復映像

現在,您可以使用備用源 (install.esd) 運行部署映像服務和管理工具 (DISM)。 esd/wim) 映像以修復本地映像。

在提升模式下打開命令提示符。然後,複製粘貼以下命令並按 Enter 鍵修復 Windows 11 映像。

DISM/Online/Cleanup-Image/RestoreHealth/Source:N:\Sources\install.esd

DISM/Online/Cleanup-Image/RestoreHealth/Source:N:\Sources\install.wim

在這裡,替換源驅動器號(N:使用 install.esd/install.wim 文件所在位置的路徑)使用文件資源管理器中的 ISO 掛載點或可啟動 USB 驅動器。如果您已安裝映像或可啟動 USB,則可以在此處使用它們的驅動器號。

限制使用DISM 的 Windows 更新,請按照下列步驟操作:

install.esd/install.wim 可能在同一映像中包含多個版本。因此,首先,您需要找出與您計算機上安裝的 Windows 11 版本相對應的索引號。為此,請輸入以下命令:

dism/get-wiminfo/wimfile:N:\sources\install.esd

dism/get-wiminfo/wimfile:N:\sources\ install.wim

現在,記下您在計算機上安裝的 Windows 版本的索引號。

現在,執行以下命令:

語法:

dism/Online/Cleanup-Image/RestoreHealth/Source:wim::\sources\ install.wim:/limitaccess

在此處,將 替換為適當的值。

示例:

DISM/Online/Cleanup-Image/RestoreHealth/Source:esd:N:\Sources\install.esd:6/LimitAccess

DISM/Online/Cleanup-Image/RestoreHealth/Source:wim:N:\ Sources\install.wim:6/LimitAccess

此處的/LimitAccess 參數阻止 DISM 聯繫 Windows 更新。

也可以使用該命令離線修復Windows鏡像:

Dism/Image:C:\/Cleanup-Image/RestoreHealth/Source:N:\Sources\install.esd

將 N:\Sources\install.esd 更改為 Windows 11 映像的路徑,將 C: 更改為 Window 的根目錄或系統目錄。

使用 DISM 安裝 Windows 更新

Windows 更新服務並不總是正常工作,有時它無法啟動、禁用或在特定更新上崩潰。此外,Windows 更新僅安裝最新的可用更新,它不允許您在系統上安裝特定更新。在這種情況下,您可以使用內置的 DISM 手動安裝特定的 Windows 11 更新。

首先,請訪問 Microsoft 更新目錄 存儲庫並從列表中下載所需的更新(關鍵更新、安全更新和更新)。如果您已經知道所需更新的 Microsoft 知識庫 ID 號(例如 KB5014019),請在左上角的搜索字段中進行搜索。

或者,您可以在搜索字段中搜索“Windows 11”以獲取已發佈到穩定版本的所有可用更新的列表。

從列表中找到您要下載的更新,然後點擊對應的“下載”按鈕。

這將打開下載頁面在新窗口上下載鏈接。只需單擊鏈接並在本地驅動器中選擇一個位置來保存文件。文件類型可能是“.cab”或“.msu”,具體取決於更新類型。

將 Windows 更新包添加到映像

在 DISM 命令中,您可以使用/Add-Package 開關將 Windows 更新添加到 Window 映像。該命令的語法如下:

Dism/Add-Package/PackagePath: [/IgnoreCheck] [/PreventPending]

示例:

要將更新包添加到正在運行的 Windows 安裝,請使用以下命令:

Dism/Online/Add-Package/PackagePath=”C:\Users\rajst\OneDrive\Documents\New folder\windows10.0-kb5014039-x64_045d1b25ac6d875123db6de219e056f5dac11295.cab”/LogPath=C:\mount\dism.log

In the above command, replaceC:\Users\rajst\OneDrive\Documents\New folder\windows10.0-kb5014039-x64_045d1b25ac6d875123db6de219e056f5dac11295.cab with the下載的更新文件名及其位置。

向 Windows 安裝添加多個更新:

Dism/Online/Add-Package/PackagePath=”C:\Users\rajst\OneDrive\Documents\新建文件夾\windows10.0-kb5014039-x64_045d1b25ac6d875123db6de219e056f5dac11295.cab”/PackagePath=”C:\Users\rajst\OneDrive\Documents\新文件夾\windows10.0-kb5013943-arm64_d5a0aeff​​704eefab25f8674d8c01e01d476ff0b9.msu”/PackagePath=”C:\Users\rajst\OneDrive\Documents\New folder\windows10.0-kb5012678-x64_b6e01cb1801810d1581e29dede0e48f635521e44.cab”/LogPath=C:\mount\dism.log

After installing the updates ,您可以檢查添加的包是否出現在系統中的包列表中:

dism/online/Get-Packages

使用 DISM 工具刪除 Windows 更新

您還可以使用 DISM 工具從命令提示符或 Windows 恢復環境中刪除已安裝的 Windows 更新。如果您遇到錯誤或 Windows 無法啟動,您可以使用此方法從 Windows 11 PC 中刪除最近安裝的更新。

以管理權限打開命令提示符。然後,運行以下命令查看計算機上所有最近安裝的軟件包和更新的列表:

DISM/Online/get-packages/format:table

從“包標識”列中,查找要卸載的更新的包名稱。您還可以使用安裝時間和日期確認要刪除的軟件包。

要獲取有關特定軟件包或更新的更多詳細信息,請嘗試以下命令:

DISM/online/get-packageinfo/packagename:PackageName

例如:

DISM/online/get-packageinfo/packagename:Package_for_ServicingStack_1011~31bf3856ad364e35~amd64~~25145.1011.1.0

刪除更新包的語法:

DISM/Online/Remove-Package/PackageName:PackageName

例如卸載更新名稱’Package_for_ServicingStack_1011~31bf3856ad364e35~amd64~~25145.1011.1.0’,運行下面的命令:

DISM/Online/Remove-Package/PackageName:Package_for_ServicingStack_1011~31bf3856ad364e35~amd64~~25145.1261″1寬度。=”572″src=”數據:image/svg+xml;charset=utf-8,%3Csvg%20xm lns%3D’http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg’%20viewBox%3D’0%200%201260%20572’%2F%3E”>

使用 DISM 啟用或禁用 Windows 功能

使用 DISM,您還可以在.wim 或.vhd 文件(掛載的 ISO)上離線啟用或禁用 Windows 功能,或在正在運行的操作系統上在線啟用或禁用 Windows 功能。您可以這樣做:

首先,使用管理權限打開命令提示符。現在,使用以下命令列出 Windows 11 中的所有可用功能:

DISM/online/Get-Features

從功能列表中找到您要啟用或禁用的功能。

一旦您找到一個特定的功能,您可以使用/Get-FeatureInfo 開關獲得有關該功能的更多詳細信息。例如:

DISM/online/Get-FeatureInfo/FeatureName:TelnetClient

使用 DISM 啟用 Windows 11 功能

如果要在 Windows 11 中啟用特定功能,可以使用 Enable-Feature 參數:

DISM/online/Enable-Feature/FeatureName:TelnetClient/All

如果要離線啟用掛載映像中的功能,則需要使用/image 參數指定掛載目錄。

DISM/Image:D:\Win11OS\offline/Enable-Feature/FeatureName:TelnetClient/All

上例中,將 D:\Win11OS\offline 替換為掛載鏡像的位置。

啟用後功能,您可以使用“Get-FeatureInfo”來 f ind 功能的狀態。

DISM/online/Get-FeatureInfo/FeatureName:TelnetClient

如果您指定多個/Source 選項,則 DISM 使用來自第一個源參數的文件,其餘位置為忽略:

Dism/Online/Enable-Feature/FeatureName:TelnetClient/Source:N:\sources\SxS/Source:C:\test\mount\windows/LimitAccess

使用 DISM 禁用 Windows 11 功能

如果您想從操作系統禁用特定功能,請使用以下命令:

DISM/online/Disable-Feature/FeatureName:TelnetClient

如果要離線禁用掛載映像中的某個功能,則需要使用/image 參數指定掛載目錄。

DISM/Image:D:\ Win11OS\offline/Disable-Feature/FeatureName:TelnetClient

上例中,替換為D:\Win11OS\offl與已安裝映像的位置一致。

使用 DISM 刪除 Windows 11 功能

如果您想從 Windows 安裝中刪除特定功能,而不必從映像中刪除該功能.為此,請輸入以下命令:

DISM/online/Disable-Feature/FeatureName:TelnetClient/Remove

如果要脫機刪除掛載映像中的功能,則需要使用指定掛載目錄/image 參數:

DISM/Image:D:\Win11OS\offline/Disable-Feature/FeatureName:TelnetClient/Remove

DISM 失敗 Windows 11 上的錯誤

在 Windows 11 上運行 DISM 命令時,您可能會遇到很多問題。以下是用戶報告的一些最常見問題:

DISM failed no operation was executed-這是使用/restorehealth 參數時最常見的錯誤之一。可以通過使用 Windows 11 ISO 文件破壞 DISM 來修復它。 DISM failed 0x8000ffff, 0x800f0954, 0x800f0950, 0x800f0906, 0x800f081f(找不到源文件。使用“Source”選項指定恢復功能所需文件的位置。) –這是您從 DISM 操作中遇到的另一個常見錯誤,這通常是由於沒有直接訪問 Internet 或 Windows 更新服務被禁用/失敗引起的。在這種情況下,請使用可引導的 USB 閃存驅動器、ISO 映像或 install.wim (esd) 文件和 Windows 安裝映像來執行 DISM 掃描。 DISM 在處理命令 cleanup-image、add-package 時失敗-可以通過使用/StartComponentCleanup 開關清理系統映像組件或重置 Windows 更新服務來解決此問題。 嘗試複製引導文件時 DISM 失敗-這是一個常見的 DISM 問題,可以通過使用/StartComponentCleanup 開關清理系統映像組件來解決。 Dism.exe 無法驗證命令行以加載 wim 管理器-如果您遇到此問題,可以通過重新啟動 Windows 更新組件來解決。 DISM 無法加載提供程序、卸載脫機註冊表、刷新文件緩衝區、設置 windows 目錄、掛載映像-這些問題可以通過檢查您的防病毒軟件、清理系統映像組件來解決、重置 Windows 更新服務,或複制並指定 Install.wim 文件的正確位置。

DISM 命令在 Windows 11 上不起作用?

DISM 不起作用並顯示以上 Windows 11 錯誤列表的原因有多種。您可以使用以下方法修復大部分問題。

清理組件存儲

大多數DISM問題是由系統映像組件損壞引起的,可以通過分析和清理系統組件存儲來修復。 DISM 有一組命令來刷新 DISM 工具。

首先,您需要使用 DISM 參數中的/AnalyzeComponentStore 參數來分析組件存儲。

要分析組件存儲運行下面的命令:

DiSM/Online/Cleanup-Image/AnalyzeComponentStore

等待進程結束,然後你會看到類似下面的信息:

Windows Explorer Reported Size of Component Store:7.48 GB。組件實際大小:7.45 GB 上次清理日期:2022-06-12:23:13:57。可回收包的數量:0。推薦的組件存儲清理:是或否。

如果“推薦的組件存儲清理”為“是”,那麼您需要繼續進行清理操作。

要運行組件清理,請輸入以下命令:

DISM/Online/Cleanup-Image/StartComponentCleanup

此命令將從組件存儲中刪除所有過時的文件或更新組件的先前版本。

如果上面的命令沒有’不解決您的問題,然後使用/ResetBase 參數重置組件存儲大小並減小其大小。為此,請使用以下命令:

DISM/Online/Cleanup-Image/StartComponentCleanup/ResetBase

或者,您使用/Defer 開關將清理操作推遲或安排到下一次自動系統維護。

DiISM/Online/Cleanup-Image/StartComponentCleanup/ResetBase/Defer

恢復所有掛起的 DISM 任務,包括 Windows 更新,運行以下命令:

DISM.exe/image:C:/cleanup-image/revertpendingactions

運行 CHKDSK

如果您遇到與磁盤相關的 DISM 問題,請運行在管理員模式下的命令提示符下執行以下命令:

chkdsk/offlinescanandfix

由於您的系統當前使用的是 C 盤,它會在下次系統重新啟動時詢問您是否安排掃描。鍵入“Y”,然後按 Enter。

然後,重新啟動您的電腦以運行 chkdsk 掃描。

重置 Windows更新服務

DISM 使用 Windows 更新服務來下載和修復或替換 Windows 映像中損壞的文件。如果 Windows 更新服務無法啟動或無法正常工作,您可以嘗試重置 Windows 更新服務。

首先,以管理員權限啟動命令提示符。在命令提示符窗口中,輸入以下命令並回車。

net stop wuauserv

等待該過程完成,然後依次輸入以下命令:

cd %systemroot%SoftwareDistribution ren 下載 Download.old net start wuauserv net stop bits net start bits net stop cryptsvc cd %systemroot%system32 ren catroot2 catroot2old net start cryptsvc

成功完成命令後,Windows Update 服務將重新啟動並出現 DISM 問題已修復。

禁用代理服務

如果 DISM 無法連接到 Internet 或無法在您的系統上運行,可能是由於您的 PC 上的代理配置所致。要解決此問題,您需要禁用設備上的代理。

首先,按 Win+I 快捷方式打開 Windows 設置。在設置應用程序中,轉到左側的“網絡和互聯網”部分,然後單擊右側的“代理”選項。

在代理設置頁面,關閉“自動代理設置”和“手動代理設置”下的所有設置。

更改遠程過程調用 (RPC) 服務的啟動類型

如果您看到 DISM failed 1726 錯誤,可能是由於當遠程過程調用 (RPC) 服務被禁用或無法自動啟動時。

遠程過程調用 (RPC) 是一種進程間通信協議或技術,它允許程序向位於網絡上另一台計算機上的另一程序請求服務,就好像它是一個本地系統一樣。它負責構建分佈式的、基於客戶端-服務器的應用程序。

It is a Service Control Manager for Component Object Model (COM) and the Distributed Component Object Model (DCOM) servers. If this communication protocol is disabled, then all the services and applications that depend on the COM and DCOM (like DISM) will not work properly. Here’s how you can change the startup method for RPC and make sure it is running properly:

First, press Windows+R keys simultaneously to launch the Run dialogue box. Then, type ‘services.msc’ in the text field and hit Enter.

Alternatively, you can just search for ‘services’ in the Windows search and open the top result.

In the Services window, scroll down and locate the service named ‘Remote Procedure Call’. There will be two services named Remote Procedure Call – Remote Procedure Call (RPC) and Remote Procedure Call (RPC) Locator.

Now, right-click the ‘Remote Procedure Call (RPC)’ service and select ‘Properties’ or just double-click on it.

Under the General tab of the Properties window, click the drop-down menu next to ‘Startup’ type and change it to ‘Automatic’. Then, click ‘Apply and then ‘OK’.

This will automatically start the RPC service when you start your system and fix the DISM 1726 error.

Also, double-click on the ‘Remote Procedure Call (RPC) Locater’ service and make sure its Startup type is set to ‘Manual’.

Then restart the computer to apply the changes. If you are still encountering the problem, try the next solution.

Modify the Value of the RpcSs Registry Key

If the DISM failed 1726 error is not resolved by the above method, you need to change the RpcSs registry value to fix the issue. Follow these instructions to edit the RpcSc registry key:

Open the Run command box by pressing Win+R simultaneously. Then, type ‘regedit’ and hit Enter. If you see the User Account Control (UAC) prompt box, click ‘Yes’.

Before we modify the registry, it is safe to backup your registry, so you can revert the changes if something goes wrong. To do this, click the ‘File’ menu and select ‘Export’.

Then, give a name for the backup file, choose whether you want to back up the whole registry or the selected branch in the registry (under Export range), and then select the destination folder. After that, click the ‘Save’ button.

After backing up the registry, navigate the following location or copy-paste the below path in the address field:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RpcSs

In the right-side panel of the ‘RpcSc’ key, double-click on the ‘Start’ DWORD to edit it.

Now, set the ‘Value data’ of Start to 2 and press ‘OK’ to save the changes.

After that, close the registry editor and restart your PC to apply the changes.

Correct the Location of the Install.esd File

If you are encountering the “Cannot find source files” or “The system cannot find the path specified”, it means the location you specified for the Install.esd file in the Source option is incorrect.

Open elevated Command Prompt. Then enter the below command and hit Enter:

DISM/Online/Cleanup-Image/RestoreHealth/source:ESD:X:SourcesInstall.esd:2/LimitAccess

In the above command make sure to replace X with the drive letter of the mounted ISO file or the drive letter of the bootable USB.

Temporarily Disable Windows Search Service

If you are encountering DISM Error 87 or the remote procedure call failed error, disabling the Windows Search service while running the DISM command can help resolve the issue. Windows Search service is a search service that allows you to search for files and apps within the system. Follow these instructions to disable the Windows search service:

Open the Run command box (press Windows+R), type ‘services.msc’, and hit Enter to open the Services window.

In the Services window, scroll down to the ‘Windows search’ service, right-click on it and select ‘Properties’. Or you can just right-click on it.

Then, under the General tab, change the ‘Startup type’ to ‘Disabled’.

After that, click ‘Apply’ and then ‘OK’.

This will temporarily stop the Windows search services temporarily. You can disable the service whenever the error occurs, then re-enable it after the DISM commands are executed successfully.

Run DISM Command in Clean Boot Mode (Offline)

Sometimes DISM failure occurs due to conflicts of services that are running in the background. So, executing the DISM commands in a clean boot may prevent these problems. Here’s how you can run DISM commands in Clean boot mode:

First, open Windows Settings by right-clicking the Start menu and selecting ‘Settings’.

In the Settings app, go to the ‘System’ tab and click on the ‘Recovery’ option on the right pane.

On the Recovery page, click the ‘Restart now’ button on the Advanced startup tile under Recovery.

Click the ‘Restart now’ button again to restart your PC.

The windows will boot your system into Windows Recovery Environment.

If your computer is not booting properly for you access the above settings. You can use this alternative way to access the Windows Recovery Environment (WinRE).

Using Hard Reboot

First, shut down your PC or turn off your PC and then press the power button to turn on the system. And just when Windows starts loading, press and hold the power button to force shutdown your PC.

Repeat these steps two or three times and the fourth time let Windows load normally. It will automatically boot into Windows Recovery Environment (WinRE). When the automatic repair screen appears, click ‘Advanced Options’.

Then select the ‘Troubleshoot’ option in the Choose an option screen.

On the next screen, choose ‘Advanced options’.

On the Advanced options screen, select the ‘Command Prompt’ option.

The Command Prompt will start with X:\Windows \System32 which is not Windows installation location. You need to find out where Windows is installed using diskpart command.

First, type diskpart to manage drives.

Next, enter list volume to get a list of all the volumes or drives connected to your system. Then, find the volume or drive in which Windows is installed. The Windows drive (which would have a different drive letter instead of C) will have no name or label. Also, you can locate the Windows drive by its size if you already know it. Note down the Windows drive letter from this list.

In the below screen, Volum 3 ‘F’ is the Windows drive. Now, note down the Windows drive letter that we are going to use to run DISM commands.

After that type exit to leave diskpart.

Then, enter the below command to run DISM scan in clean boot:

DISM/image:F:\/cleanup-image/restorehealth

If you are booting from a Windows installation media or have a Windows 11 iso file connected to your computer on a bootable drive, you can use the following DISM command to repair the Windows image offline:

Dism/image:F:\/Cleanup-Image/RestoreHealth/Source:N:\sources\install.esd

or

Dism/image:F:\/Cleanup-Image/RestoreHealth/Source:N:\sources\install.wim

Where F: is the Windows 11 d rive and N: is where we have the Windows installation media.

In case you don’t have enough space on the selected drive, you will need to specify an empty directory on a separate drive to perform the repair operation. To do that follow these steps:

First, create a folder named ‘scratch’ on that separate drive. You can also use the mkdir G:\scratch to create the folder.

Then, enter the below command to repair the component store using the ScratchDir:

Dism/image:F:\/Cleanup-Image/RestoreHealth/Source:N:\sources\install.esd/ScratchDir:G:\scratch

Here, we specified the scratch directory location using the/ScratchDir switch. Wait for the repair operation to finish, then restart your PC.

Copy-Paste install.wim/esd (from the boot drive to the local C: drive)

If the DISM cannot access the install.wim/esd file from the Windows bootable drive or installation disc, you can copy install.wim/esd file from to the local C: drive.

First, insert the Windows 11 bootable drive or the installation disc into your PC. Alternatively, you can also mount the Windows ISO file and create a boot drive.

Then, find the install.esd/wim file from the installation files and copy it with Ctrl+C. It is probably located inside the Source directory of the installation files.

Next, paste the copied files inside the ‘local C:’ drive (system drive) by pressing Ctrl+V. You don’t have to paste the file in any particular folder just inside the C: drive.

After that open Command Prompt with administrative privileges.

Then, enter the below command in the command prompt to repair Windows:

DISM/Online/Cleanup-Image/RestoreHealth/source:WIM:C:\Install.wim:1/LimitAccess

Disable Read-Only Option in Install.esd

Sometimes, the Install.esd may not work, even after copying it to the local C drive. In such cases, make sure the Install.esd or Install.wim file is not in read-only mode. Here’s how you do this:

On the File Explorer, navigate to the Install.esd file on your system. Then, right-click on the file and select ‘Properties’.

Then, uncheck the ‘Read-only’ option next to Attributes, click ‘Apply’, and then ‘OK’.

Repair Windows Image Using Cleanup-MountPoints Argument

Sometimes, when altering the Windows image with DISM, the image can get corrupted. It can be easily fixed by cleaning up the mount points of your image.

Use the /Cleanup-MountPoints option with DISM as shown below:

Dism/Cleanup-Mountpoints

That’s it.

Categories: IT Info