-
Notifications
You must be signed in to change notification settings - Fork 0
/
DISM_and_SFC_Scan.cmd
59 lines (48 loc) · 1.61 KB
/
DISM_and_SFC_Scan.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@echo off
setlocal enabledelayedexpansion
set "SFC_SUCCESS=0"
net session >nul 2>&1
if %errorlevel% neq 0 (
echo This script requires administrator privileges.
echo Please right-click and select "Run as administrator".
timeout /t 5 /nobreak
exit /b 1
)
cd /d "C:" >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to change to C: drive.
)
echo Checking integrity of all protected system files...
call sfc /scannow >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to check integrity of all protected system files.
SFC_SUCCESS=1
)
echo Checking for corruption in the local Windows image...
call DISM /Online /Cleanup-Image /CheckHealth >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to check for corruption in the local Windows image.
)
call DISM /Online /Cleanup-Image /ScanHealth >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to check for corruption in the local Windows image.
)
echo Repairing corruption in the local Windows image...
call DISM /Online /Cleanup-Image /RestoreHealth >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to repair corruption in the local Windows image.
)
if %SFC_SUCCESS% neq 0 (
echo Checking integrity of all protected system files...
call sfc /scannow >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to check integrity of all protected system files.
)
)
echo Deleting resources associated with corrupted mounted images...
call DISM /Cleanup-Mountpoints >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to delete resources associated with corrupted mounted images.
)
timeout /t 5 /nobreak
exit /b 0