-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUninstallEdge.cmd
221 lines (208 loc) · 11.4 KB
/
UninstallEdge.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
@echo off
:: Bye Bye Edge OneCMD Edition ::
:: Made by Useful Stuffs ::
:: Credits: ShadowWhisperer for his uninstall Edge script (some code took) ::
:init
setlocal DisableDelayedExpansion
set cmdInvoke=1
set winSysFolder=System32
set "batchPath=%~dpnx0"
rem this works also from cmd shell, other than %~0
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
if '%cmdInvoke%'=='1' goto InvokeCmd
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
goto ExecElevation
:InvokeCmd
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
:ExecElevation
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
:main
echo Checking system...
if exist "%ProgramFiles%\Microsoft\Edge" goto uninstall32
if exist "%ProgramFiles(x86)%\Microsoft\Edge" goto uninstall64
goto noedge
:uninstall32
echo Edge was found!
echo Closing Edge...
taskkill /f /t /im msedge.exe > nul
taskkill /f /t /im MicrosoftEdgeUpdate.exe > nul
taskkill /f /t /im msedgewebview2.exe > nul
echo Uninstalling Edge...
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f > nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f > nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f > nul
reg delete "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f > nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" /f > nul
net stop MicrosoftEdgeElevationService > nul
sc delete MicrosoftEdgeElevationService > nul
net stop edgeupdate > nul
sc delete edgeupdate > nul
net stop edgeupdatem > nul
sc delete edgeupdatem > nul
rd /s /q "%ProgramData%\Microsoft\EdgeUpdate" > nul
rd /s /q "%ProgramFiles%\Microsoft\Edge" > nul
rd /s /q "%ProgramFiles%\Microsoft\EdgeCore" > nul
rd /s /q "%ProgramFiles%\Microsoft\EdgeUpdate" > nul
rd /s /q "%ProgramFiles%\Microsoft\EdgeWebView" > nul
rd /s /q "%ProgramFiles%\Microsoft\Temp" > nul
del /f /q "%userprofile%\Desktop\Microsoft Edge.lnk" > nul
del /f /q "%systemdrive%\Users\Public\Desktop\Microsoft Edge.lnk" > nul
del /f /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" > nul
del /f /q "%appdata%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" > nul
del /f /q "%appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk" > nul
reg add "HKLM\Software\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d 1 /f > nul
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\System32\Tasks\*MicrosoftEdge*') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
for /f "delims=" %%a in ('powershell "(New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value"') do set "USER_SID=%%a"
for /f "delims=" %%a in ('powershell -NoProfile -Command "Get-AppxPackage -AllUsers | Where-Object { $_.PackageFullName -like '*microsoftedge*' } | Select-Object -ExpandProperty PackageFullName"') do (
if not "%%a"=="" (
set "APP=%%a"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\!USER_SID!\!APP!" /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\S-1-5-18\!APP!" /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\!APP!" /f >nul 2>&1
powershell -Command "Remove-AppxPackage -Package '!APP!'" 2>nul
powershell -Command "Remove-AppxPackage -Package '!APP!' -AllUsers" 2>nul
)
)
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\SystemApps\Microsoft.MicrosoftEdge*') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\System32\MicrosoftEdge*.exe') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications" /v "Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.htm\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.html\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.mht\OpenWithProgIds" /v "MSEdgeMHT" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.mhtml\OpenWithProgIds" /v "MSEdgeMHT" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf\OpenWithProgIds" /v "MSEdgePDF" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.shtml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.svg\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.webp\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xht\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xhtml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\EdgeIntegration" /f
echo Microsoft Edge should be now uninstalled.
echo Please reboot Windows.
pause
goto eof
:uninstall64
echo Edge was found!
echo Closing Edge...
taskkill /f /t /im msedge.exe > nul
taskkill /f /t /im MicrosoftEdgeUpdate.exe > nul
taskkill /f /t /im msedgewebview2.exe > nul
echo Uninstalling Edge...
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f > nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f > nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f > nul
reg delete "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f > nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" /f > nul
net stop MicrosoftEdgeElevationService > nul
sc delete MicrosoftEdgeElevationService > nul
net stop edgeupdate > nul
sc delete edgeupdate > nul
net stop edgeupdatem > nul
sc delete edgeupdatem > nul
rd /s /q "%ProgramData%\Microsoft\EdgeUpdate" > nul
rd /s /q "%ProgramFiles(x86)%\Microsoft\Edge" > nul
rd /s /q "%ProgramFiles(x86)%\Microsoft\EdgeCore" > nul
rd /s /q "%ProgramFiles(x86)%\Microsoft\EdgeUpdate" > nul
rd /s /q "%ProgramFiles(x86)%\Microsoft\EdgeWebView" > nul
rd /s /q "%ProgramFiles(x86)%\Microsoft\Temp" > nul
del /f /q "%userprofile%\Desktop\Microsoft Edge.lnk" > nul
del /f /q "%systemdrive%\Users\Public\Desktop\Microsoft Edge.lnk" > nul
del /f /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" > nul
del /f /q "%appdata%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" > nul
del /f /q "%appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk" > nul
reg add "HKLM\Software\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d 1 /f > nul
reg add "HKLM\Software\WOW6432Node\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d 1 /f > nul
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\System32\Tasks\*MicrosoftEdge*') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
for /f "delims=" %%a in ('powershell "(New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value"') do set "USER_SID=%%a"
for /f "delims=" %%a in ('powershell -NoProfile -Command "Get-AppxPackage -AllUsers | Where-Object { $_.PackageFullName -like '*microsoftedge*' } | Select-Object -ExpandProperty PackageFullName"') do (
if not "%%a"=="" (
set "APP=%%a"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\!USER_SID!\!APP!" /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\S-1-5-18\!APP!" /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\!APP!" /f >nul 2>&1
powershell -Command "Remove-AppxPackage -Package '!APP!'" 2>nul
powershell -Command "Remove-AppxPackage -Package '!APP!' -AllUsers" 2>nul
)
)
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\SystemApps\Microsoft.MicrosoftEdge*') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\System32\MicrosoftEdge*.exe') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
for /f "delims=" %%f in ('dir /s /b %SystemRoot%\SysWOW64\MicrosoftEdge*.exe') do (
takeown /f "%%f"
icacls "%%f" /grant everyone:F
del /f /q "%%f"
)
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications" /v "Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Clients\StartMenuInternet\Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\RegisteredApplications" /v "Microsoft Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.htm\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.html\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.mht\OpenWithProgIds" /v "MSEdgeMHT" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.mhtml\OpenWithProgIds" /v "MSEdgeMHT" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf\OpenWithProgIds" /v "MSEdgePDF" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.shtml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.svg\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.webp\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xht\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xhtml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xml\OpenWithProgIds" /v "MSEdgeHTM" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Edge" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\EdgeIntegration" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\EdgeIntegration" /f
echo Microsoft Edge should be now uninstalled.
echo Please reboot Windows.
pause
goto eof
:noedge
echo Preinstalled Edge Chromium was not found!
pause
:eof