-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnmountCleanUp.cmd
More file actions
116 lines (92 loc) · 2.86 KB
/
UnmountCleanUp.cmd
File metadata and controls
116 lines (92 loc) · 2.86 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
@echo off
TITLE Windows 7 Integrator Clean up script
pause
:: ## MODS:
:: ## 1. pause
CLS
::
:: This script is only needed if execution of Integrate7 gets interrupted,
:: leaving garbage behind.
::
:: Orherwise, It has no effect because normally Integrate7 has built in clean up.
::
REM Check admin rights
fsutil dirty query %systemdrive% >nul 2>&1
if ERRORLEVEL 1 (
ECHO.
ECHO.
ECHO ===================================================================
ECHO The script needs Administrator permissions!
ECHO.
ECHO Please run it as the Administrator or disable User Account Control.
ECHO ===================================================================
ECHO.
PAUSE >NUL
goto end
)
REM Check parenthesis in script PATH, which brakes subsequent for loops
set incorrectPath=0
echo "%~dp0" | findstr /l /c:"(" >nul 2>&1 && set incorrectPath=1
echo "%~dp0" | findstr /l /c:")" >nul 2>&1 && set incorrectPath=1
if not "%incorrectPath%"=="0" (
ECHO.
ECHO.
ECHO ================================================================
ECHO Script cannot be run from this location!
ECHO Current location contatins parenthesis in the PATH.
ECHO.
ECHO Please copy and run script from Desktop or another directory!
ECHO ================================================================
ECHO.
PAUSE >NUL
goto end
)
set "HostArchitecture=x86"
If exist "%WinDir%\SysWOW64" set "HostArchitecture=amd64"
set "PF=%ProgramFiles%"
if not "%ProgramFiles(x86)%"=="" set "PF=%ProgramFiles(x86)%"
ECHO.
ECHO.
ECHO ================================================================
ECHO Unmounting mounted registry keys...
ECHO ================================================================
ECHO.
reg unload HKLM\TK_DEFAULT >nul 2>&1
reg unload HKLM\TK_NTUSER >nul 2>&1
reg unload HKLM\TK_SOFTWARE >nul 2>&1
reg unload HKLM\TK_SYSTEM >nul 2>&1
reg unload HKLM\TK_COMPONENTS >nul 2>&1
ECHO.
ECHO Done!
ECHO.
ECHO.
ECHO.
ECHO ================================================================
ECHO Unmounting mounted images...
ECHO ================================================================
ECHO.
for /L %%i in (1, 1, 10) do (
if exist "%~dp0mount\%%i\Windows\explorer.exe" (
"%~dp0tools\%HostArchitecture%\DISM\dism.exe" /Unmount-Wim /MountDir:"%~dp0mount\%%i" /Discard
)
)
if exist "%~dp0mount\Boot\Windows\regedit.exe" (
"%~dp0tools\%HostArchitecture%\DISM\dism.exe" /Unmount-Wim /MountDir:"%~dp0mount\Boot" /Discard
)
if exist "%~dp0Win10_Installer\mount\Windows\explorer.exe" (
"%~dp0tools\%HostArchitecture%\DISM\dism.exe" /Unmount-Wim /MountDir:"%~dp0Win10_Installer\mount" /Discard
)
rd /s /q "%~dp0mount" >nul 2>&1
rd /s /q "%~dp0Win10_Installer\mount" >nul 2>&1
mkdir "%~dp0mount" >nul 2>&1
rd /s /q "%~dp0hotfixes\unpacked" >nul 2>&1
"%~dp0tools\%HostArchitecture%\DISM\dism.exe" /Cleanup-Mountpoints
ECHO.
ECHO.
ECHO All done!
ECHO.
ECHO.
ECHO Press any key to end the script.
ECHO.
PAUSE >NUL
:end