-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsxscleanup.bat
103 lines (91 loc) · 2.71 KB
/
sxscleanup.bat
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
@echo off
setlocal enabledelayedexpansion
set log_file=%temp%\sxscleanup.log
set timestamp=%date% %time:~0,8%
:initialize
cls
echo Initializing...
echo Initializing... >> %log_file%
goto :main_menu
:main_menu
cls
echo Select an option:
echo 1. StartComponentCleanup
echo 2. StartComponentCleanup with ResetBase
echo 3. SPSuperseded
echo 4. Silent mode (all tasks)
echo 5. Help
echo 6. Exit
set /p choice=Choose an option:
if "!choice!"=="1" call :StartComponentCleanup
if "!choice!"=="2" call :StartComponentCleanup_ResetBase
if "!choice!"=="3" call :SPSuperseded
if "!choice!"=="4" goto :silent_mode
if "!choice!"=="5" goto :show_help
if "!choice!"=="6" goto :exit_script
goto :main_menu
:StartComponentCleanup
@echo on
echo !timestamp!: Running StartComponentCleanup... >> %log_file%
Dism.exe /online /Cleanup-Image /StartComponentCleanup >> %log_file% 2>&1
if !errorlevel! neq 0 (
echo !timestamp!: Failed to run StartComponentCleanup. See %log_file% for details.
pause
goto :eof
)
@echo off
goto :main_menu
:StartComponentCleanup_ResetBase
@echo on
echo !timestamp!: Running StartComponentCleanup with ResetBase... >> %log_file%
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase >> %log_file% 2>&1
if !errorlevel! neq 0 (
echo !timestamp!: Failed to run StartComponentCleanup with ResetBase. See %log_file% for details.
pause
goto :eof
)
@echo off
goto :main_menu
:SPSuperseded
@echo on
echo !timestamp!: Running SPSuperseded... >> %log_file%
Dism.exe /online /Cleanup-Image /SPSuperseded >> %log_file% 2>&1
if !errorlevel! neq 0 (
echo !timestamp!: Failed to run SPSuperseded. See %log_file% for details.
pause
goto :eof
)
@echo off
goto :main_menu
:silent_mode
set /p display_output="Display output? (y/n): "
if "!display_output!"=="y" (
@echo on
Dism.exe /online /Cleanup-Image /StartComponentCleanup
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
Dism.exe /online /Cleanup-Image /SPSuperseded
@echo off
) else (
@echo off
Dism.exe /online /Cleanup-Image /StartComponentCleanup > NUL
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase > NUL
Dism.exe /online /Cleanup-Image /SPSuperseded > NUL
)
goto :eof
:show_help
cls
echo Help:
echo 1. StartComponentCleanup: Cleans up superseded components to reduce space.
echo 2. StartComponentCleanup with ResetBase: Cleans up and resets base component store.
echo 3. SPSuperseded: Removes superseded Service Pack files.
echo 4. Silent mode: Runs all cleanup tasks without user intervention.
echo Press any key to return to the main menu.
pause > nul
goto :main_menu
:exit_script
echo Cleaning up and exiting...
echo Cleaning up and exiting... >> %log_file%
goto :eof
:eof
endlocal
exit /b