| 1 | @(set "0=%~f0"^)#) & powershell -nop -c iex([io.file]::ReadAllText($env:0)) & exit /b
|
| 2 | #:: just copy-paste into powershell - it's a standalone hybrid script
|
| 3 | sp 'HKCU:\Volatile Environment' 'Edge_Removal' @'
|
| 4 |
|
| 5 | $also_remove_webview = 1
|
| 6 | ## why also remove webview? because it is 2 copies of edge, not a slimmed down CEF, and is driving bloated web apps
|
| 7 | $also_remove_widgets = 1
|
| 8 | ## why also remove widgets? because it is a webview glorified ad portal on msn and bing news cathering to stupid people
|
| 9 | $also_remove_xsocial = 1
|
| 10 | ## why also remove xsocial? because it starts webview setup every boot - xbox gamebar will still work without the social crap
|
| 11 |
|
| 12 | $host.ui.RawUI.WindowTitle = 'Edge Removal - AveYo, 2023.09.14'
|
| 13 | write-host "Run the script again whenever you need to reinstall and update edge or webview..`n"
|
| 14 | $remove_appx = @("MicrosoftEdge"); $remove_win32 = @("Microsoft Edge","Microsoft Edge Update"); $skip = @() # @("DevTools")
|
| 15 | if ($also_remove_webview -eq 1) {$remove_appx += "Win32WebViewHost"; $remove_win32 += "Microsoft EdgeWebView"}
|
| 16 | if ($also_remove_widgets -eq 1) {$remove_appx += "WebExperience"}
|
| 17 | if ($also_remove_xsocial -eq 1) {$remove_appx += "GamingServices"}
|
| 18 |
|
| 19 | $global:WEBV = $also_remove_webview -eq 1
|
| 20 | $global:IS64 = [Environment]::Is64BitOperatingSystem
|
| 21 | $global:IFEO = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
|
| 22 | $global:EDGE_UID = '{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}'
|
| 23 | $global:WEBV_UID = '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
|
| 24 | $global:UPDT_UID = '{F3C4FE00-EFD5-403B-9569-398A20F1BA4A}'
|
| 25 | $global:PROGRAMS = ($env:ProgramFiles, ${env:ProgramFiles(x86)})[$IS64]
|
| 26 | $global:SOFTWARE = ('SOFTWARE', 'SOFTWARE\WOW6432Node')[$IS64]
|
| 27 | $global:ALLHIVES = 'HKCU:\SOFTWARE','HKLM:\SOFTWARE','HKCU:\SOFTWARE\Policies','HKLM:\SOFTWARE\Policies'
|
| 28 | if ($IS64) { $global:ALLHIVES += "HKCU:\$SOFTWARE","HKLM:\$SOFTWARE","HKCU:\$SOFTWARE\Policies","HKLM:\$SOFTWARE\Policies"}
|
| 29 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 30 |
|
| 31 | ## 1 bonus! enter into powershell console: firefox / edge / webview to install a browser / reinstall edge / webview after removal
|
| 32 | function global:firefox { $url = 'https://download.mozilla.org/?product=firefox-stub'
|
| 33 | $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\Firefox Installer.exe"
|
| 34 | write-host $url; Invoke-WebRequest $url -OutFile $setup; start $setup
|
| 35 | }
|
| 36 | function global:edge { $url = 'https://go.microsoft.com/fwlink/?linkid=2108834&Channel=Stable&language=en'
|
| 37 | $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\MicrosoftEdgeSetup.exe"
|
| 38 | write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_EDGE; start $setup
|
| 39 | }
|
| 40 | function global:webview { $url = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703'
|
| 41 | $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\MicrosoftEdgeWebview2Setup.exe"
|
| 42 | write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_WEBVIEW; start $setup
|
| 43 | }
|
| 44 | function global:xsocial { $url = 'https://dlassets-ssl.xboxlive.com/public/content/XboxInstaller/XboxInstaller.exe'
|
| 45 | $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\XboxInstaller.exe"
|
| 46 | write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_WEBVIEW; start $setup
|
| 47 | }
|
| 48 |
|
| 49 | ## helper for set-itemproperty remove-itemproperty new-item remove-item with auto test-path
|
| 50 | function global:sp_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Set-ItemProperty @args} else {
|
| 51 | Microsoft.PowerShell.Management\New-Item $args[0] -force -ea 0 >''; Microsoft.PowerShell.Management\Set-ItemProperty @args} }
|
| 52 | function global:rp_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Remove-ItemProperty @args} }
|
| 53 | function global:ni_test_path { if (-not (test-path $args[0])) {Microsoft.PowerShell.Management\New-Item @args} }
|
| 54 | function global:ri_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Remove-Item @args} }
|
| 55 | foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
|
| 56 |
|
| 57 | ## helper for edgeupdate reinstall
|
| 58 | function global:PREPARE_UPDT($cdp='msedgeupdate', $uid=$UPDT_UID) {
|
| 59 | foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
|
| 60 | foreach ($sw in $ALLHIVES) {
|
| 61 | rp "$sw\Microsoft\EdgeUpdate" 'DoNotUpdateToEdgeWithChromium' -force -ea 0
|
| 62 | rp "$sw\Microsoft\EdgeUpdate" 'UpdaterExperimentationAndConfigurationServiceControl' -force -ea 0
|
| 63 | rp "$sw\Microsoft\EdgeUpdate" "InstallDefault" -force -ea 0
|
| 64 | ## rp "$sw\Microsoft\EdgeUpdate" "Install${uid}" -force -ea 0
|
| 65 | rp "$sw\Microsoft\EdgeUpdate" "EdgePreview${uid}" -force -ea 0
|
| 66 | rp "$sw\Microsoft\EdgeUpdate" "Update${uid}" -force -ea 0
|
| 67 | rp "$sw\Microsoft\EdgeUpdate\ClientState\*" 'experiment_control_labels' -force -ea 0
|
| 68 | ri "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands" -recurse -force -ea 0
|
| 69 | rp "$sw\Microsoft\EdgeUpdateDev\CdpNames" "$cdp-*" -force -ea 0
|
| 70 | sp "$sw\Microsoft\EdgeUpdateDev" 'CanContinueWithMissingUpdate' 1 -type Dword -force
|
| 71 | sp "$sw\Microsoft\EdgeUpdateDev" 'AllowUninstall' 1 -type Dword -force
|
| 72 | }
|
| 73 | }
|
| 74 | ## helper for edge reinstall - remove bundled OpenWebSearch redirector and edgeupdate policies
|
| 75 | function global:PREPARE_EDGE {
|
| 76 | foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
|
| 77 | PREPARE_UPDT 'msedge' $EDGE_UID; PREPARE_UPDT 'msedgeupdate' $UPDT_UID
|
| 78 | $MSEDGE = "$PROGRAMS\Microsoft\Edge\Application\msedge.exe"
|
| 79 | ri "$IFEO\msedge.exe" -recurse -force; ri "$IFEO\ie_to_edge_stub.exe" -recurse -force
|
| 80 | ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\microsoft-edge' -recurse -force
|
| 81 | sp 'HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command' '(Default)' "`"$MSEDGE`" --single-argument %%1" -force
|
| 82 | ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\MSEdgeHTM' -recurse -force
|
| 83 | sp 'HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command' '(Default)' "`"$MSEDGE`" --single-argument %%1" -force
|
| 84 | }
|
| 85 | ## helper for webview reinstall - restore webexperience (widgets) if available
|
| 86 | function global:PREPARE_WEBVIEW {
|
| 87 | PREPARE_UPDT 'msedgewebview' $WEBV_UID; PREPARE_UPDT 'msedgeupdate' $UPDT_UID
|
| 88 | $cfg = @{Register=$true; ForceApplicationShutdown=$true; ForceUpdateFromAnyVersion=$true; DisableDevelopmentMode=$true}
|
| 89 | dir "$env:SystemRoot\SystemApps\Microsoft.Win32WebViewHost*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg
|
| 90 | dir "$env:ProgramFiles\WindowsApps\MicrosoftWindows.Client.WebExperience*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg
|
| 91 | kill -name explorer -ea 0; if ((get-process -name 'explorer' -ea 0) -eq $null) {start explorer}
|
| 92 | }
|
| 93 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 94 |
|
| 95 | ## 2 enable admin privileges
|
| 96 | $D1=[uri].module.gettype('System.Diagnostics.Process')."GetM`ethods"(42) |where {$_.Name -eq 'SetPrivilege'} #`:no-ev-warn
|
| 97 | 'SeSecurityPrivilege','SeTakeOwnershipPrivilege','SeBackupPrivilege','SeRestorePrivilege'|foreach {$D1.Invoke($null, @("$_",2))}
|
| 98 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 99 |
|
| 100 | ## 3 shut down edge & webview clone stuff
|
| 101 | cd $env:systemdrive; taskkill /im explorer.exe /f 2>&1 >''
|
| 102 | $shut = 'explorer','Widgets','widgetservice','msedgewebview2','MicrosoftEdge*','chredge','msedge','edge'
|
| 103 | $shut,'msteams','msfamily','WebViewHost','Clipchamp' |foreach {kill -name $_ -force -ea 0}
|
| 104 |
|
| 105 | ## clear win32 uninstall block
|
| 106 | foreach ($name in $remove_win32) { foreach ($sw in $ALLHIVES) {
|
| 107 | $key = "$sw\Microsoft\Windows\CurrentVersion\Uninstall\$name"; if (-not (test-path $key)) {continue}
|
| 108 | foreach ($val in 'NoRemove','NoModify','NoRepair') {rp $key $val -force -ea 0}
|
| 109 | foreach ($val in 'ForceRemove','Delete') {sp $key $val 1 -type Dword -force}
|
| 110 | }}
|
| 111 | PREPARE_EDGE
|
| 112 |
|
| 113 | ## find all Edge setup.exe and gather BHO paths for OpenWebSearch / MSEdgeRedirect usage
|
| 114 | $edges = @(); $bho = @(); $edgeupdates = @(); 'LocalApplicationData','ProgramFilesX86','ProgramFiles' |foreach {
|
| 115 | $folder = [Environment]::GetFolderPath($_); $bho += dir "$folder\Microsoft\Edge*\ie_to_edge_stub.exe" -rec -ea 0
|
| 116 | if ($WEBV) {$edges += dir "$folder\Microsoft\Edge*\setup.exe" -rec -ea 0 |where {$_ -like '*EdgeWebView*'}}
|
| 117 | $edges += dir "$folder\Microsoft\Edge*\setup.exe" -rec -ea 0 |where {$_ -notlike '*EdgeWebView*'}
|
| 118 | $edgeupdates += dir "$folder\Microsoft\EdgeUpdate\*.*.*.*\MicrosoftEdgeUpdate.exe" -rec -ea 0
|
| 119 | }
|
| 120 |
|
| 121 | ## export OpenWebSearch innovative redirector - used by MSEdgeRedirect as well
|
| 122 | $DIR = "$env:SystemDrive\Scripts"; mkdir $DIR -ea 0 >''
|
| 123 | foreach ($b in $bho) { if (test-path $b) { try {copy $b "$DIR\ie_to_edge_stub.exe" -force -ea 0} catch{} } }
|
| 124 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 125 |
|
| 126 | ## 4 remove found *Edge* appx packages with unblock tricks
|
| 127 | $provisioned = get-appxprovisionedpackage -online; $appxpackage = get-appxpackage -allusers; $eol = @()
|
| 128 | $store = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore'
|
| 129 | $users = @('S-1-5-18'); if (test-path $store) {$users += $((dir $store -ea 0 |where {$_ -like '*S-1-5-21*'}).PSChildName)}
|
| 130 | foreach ($choice in $remove_appx) { if ('' -eq $choice.Trim()) {continue}
|
| 131 | foreach ($appx in $($provisioned |where {$_.PackageName -like "*$choice*"})) {
|
| 132 | $next = !1; foreach ($no in $skip) {if ($appx.PackageName -like "*$no*") {$next = !0}} ; if ($next) {continue}
|
| 133 | $PackageName = $appx.PackageName; $PackageFamilyName = ($appxpackage |where {$_.Name -eq $appx.DisplayName}).PackageFamilyName
|
| 134 | ni "$store\Deprovisioned\$PackageFamilyName" -force >''; $PackageFamilyName
|
| 135 | foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageName" -force >''} ; $eol += $PackageName
|
| 136 | dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
|
| 137 | remove-appxprovisionedpackage -packagename $PackageName -online -allusers >''
|
| 138 | }
|
| 139 | foreach ($appx in $($appxpackage |where {$_.PackageFullName -like "*$choice*"})) {
|
| 140 | $next = !1; foreach ($no in $skip) {if ($appx.PackageFullName -like "*$no*") {$next = !0}} ; if ($next) {continue}
|
| 141 | $PackageFullName = $appx.PackageFullName;
|
| 142 | ni "$store\Deprovisioned\$appx.PackageFamilyName" -force >''; $PackageFullName
|
| 143 | foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageFullName" -force >''} ; $eol += $PackageFullName
|
| 144 | dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
|
| 145 | remove-appxpackage -package $PackageFullName -allusers >''
|
| 146 | }
|
| 147 | }
|
| 148 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 149 |
|
| 150 | ## 5 run found *Edge* setup.exe with uninstall args and wait in-between
|
| 151 | foreach ($setup in $edges) { if (-not (test-path $setup)) {continue}
|
| 152 | if ($setup -like '*EdgeWebView*') {$target = "--msedgewebview"} else {$target = "--msedge"}
|
| 153 | $sulevel = ('--system-level','--user-level')[$setup -like '*\AppData\Local\*']
|
| 154 | $removal = "--uninstall $target $sulevel --verbose-logging --force-uninstall"
|
| 155 | try {write-host $setup $removal; start -wait $setup -args $removal} catch {}
|
| 156 | do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
|
| 157 | }
|
| 158 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 159 |
|
| 160 | ## msi installers cleanup
|
| 161 | gp 'HKLM:\SOFTWARE\Classes\Installer\Products\*' 'ProductName' |where {$_.ProductName -like '*Microsoft Edge*'} |foreach {
|
| 162 | $prod = ($_.PSChildName -split '(.{8})(.{4})(.{4})(.{4})' -join '-').trim('-')
|
| 163 | $sort = 7,6,5,4,3,2,1,0,8,12,11,10,9,13,17,16,15,14,18,20,19,22,21,23,25,24,27,26,29,28,31,30,33,32,35,34
|
| 164 | $code = '{' + -join ($sort |foreach {$prod[$_]}) + '}'; start -wait msiexec.exe -args "/X$code /qn" 2>''
|
| 165 | ri $_.PSPath -recurse -force
|
| 166 | foreach ($sw in $ALLHIVES) {ri "$sw\Microsoft\Windows\CurrentVersion\Uninstall\$code" -recurse -force}
|
| 167 | }
|
| 168 |
|
| 169 | ## 6 edgeupdate graceful cleanup
|
| 170 | if ($WEBV) {
|
| 171 | foreach ($sw in $ALLHIVES) {ri "$sw\Microsoft\EdgeUpdate" -recurse -force}
|
| 172 | foreach ($UPDT in $edgeupdates) {
|
| 173 | if (test-path $UPDT) {write-host "$UPDT /unregsvc"; start -wait $UPDT -args '/unregsvc'}
|
| 174 | do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
|
| 175 | if (test-path $UPDT) {write-host "$UPDT /uninstall"; start -wait $UPDT -args '/uninstall'}
|
| 176 | do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
|
| 177 | }
|
| 178 | Unregister-ScheduledTask -TaskName MicrosoftEdgeUpdate* -Confirm:$false -ea 0; ri "$PROGRAMS\Microsoft\Temp" -recurse -force
|
| 179 | }
|
| 180 | $appdata = $([Environment]::GetFolderPath('ApplicationData'))
|
| 181 | ri "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk" -force
|
| 182 | ri "$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk" -force
|
| 183 |
|
| 184 | ## undo eol unblock trick to prevent latest cumulative update (LCU) failing
|
| 185 | foreach ($sid in $users) { foreach ($PackageName in $eol) {ri "$store\EndOfLife\$sid\$PackageName" -force >''} }
|
| 186 |
|
| 187 | ## .i. "Update policies are configured but will be ignored because this device isn't domain joined" .i.
|
| 188 | $uids = @($EDGE_UID); $cdps = @('msedge'); if ($WEBV) {$uids += $WEBV_UID; $cdps += 'msedgewebview'}
|
| 189 | foreach ($sw in $ALLHIVES) {
|
| 190 | sp "$sw\Microsoft\EdgeUpdate" 'DoNotUpdateToEdgeWithChromium' 1 -type Dword -force
|
| 191 | sp "$sw\Microsoft\EdgeUpdate" 'UpdaterExperimentationAndConfigurationServiceControl' 0 -type Dword -force
|
| 192 | sp "$sw\Microsoft\EdgeUpdate" 'InstallDefault' 0 -type Dword -force
|
| 193 | foreach ($uid in $uids) {
|
| 194 | sp "$sw\Microsoft\EdgeUpdate" "Install${uid}" 0 -type Dword -force
|
| 195 | sp "$sw\Microsoft\EdgeUpdate" "EdgePreview${uid}" 0 -type Dword -force
|
| 196 | sp "$sw\Microsoft\EdgeUpdate" "Update${uid}" 2 -type Dword -force
|
| 197 | foreach ($trigger in 'on-os-upgrade','on-logon','on-logon-autolaunch','on-logon-startup-boost') {
|
| 198 | sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'AutoRunOnLogon' 0 -type Dword -force
|
| 199 | sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'AutoRunOnOSUpgrade' 0 -type Dword -force
|
| 200 | sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'Enabled' 0 -type Dword -force
|
| 201 | }
|
| 202 | }
|
| 203 | sp "$sw\Microsoft\MicrosoftEdge\Main" 'AllowPrelaunch' 0 -type Dword -force
|
| 204 | sp "$sw\Microsoft\MicrosoftEdge\TabPreloader" 'AllowTabPreloading' 0 -type Dword -force
|
| 205 | ## microsoft has no shame, so we are gonna insist opting-out of unsolicited reinstalls with windows updates
|
| 206 | foreach ($cdp in $cdps) { foreach ($arch in 'x64','x86') { foreach ($zdp in '','-zdp') {
|
| 207 | sp "$sw\Microsoft\EdgeUpdateDev\CdpNames" "$cdp-stable-win-$arch$zdp" "$cdp-stable-win-arm64$zdp" -force
|
| 208 | }}}
|
| 209 | }
|
| 210 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 211 |
|
| 212 | ## 7 add bundled OpenWebSearch script to redirect microsoft-edge: anti-competitive links to the default browser
|
| 213 | $MSEP = ($env:ProgramFiles,${env:ProgramFiles(x86)})[[Environment]::Is64BitOperatingSystem] + '\Microsoft\Edge\Application'
|
| 214 | $IFEO = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
|
| 215 | $MIN = ('--headless','--width 1 --height 1')[([environment]::OSVersion.Version.Build) -gt 25179]
|
| 216 | $CMD = "$env:systemroot\system32\conhost.exe $MIN" # AveYo: minimize prompt - see Terminal issue #13914
|
| 217 | ni "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" -force >''
|
| 218 | sp "HKLM:\SOFTWARE\Classes\microsoft-edge" '(Default)' 'URL:microsoft-edge' -force
|
| 219 | sp "HKLM:\SOFTWARE\Classes\microsoft-edge" 'URL Protocol' '' -force
|
| 220 | sp "HKLM:\SOFTWARE\Classes\microsoft-edge" 'NoOpenWith' '' -force
|
| 221 | sp "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" '(Default)' "`"$DIR\ie_to_edge_stub.exe`" %1" -force
|
| 222 | ni "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" -force >''
|
| 223 | sp "HKLM:\SOFTWARE\Classes\MSEdgeHTM" 'NoOpenWith' '' -force
|
| 224 | sp "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" '(Default)' "`"$DIR\ie_to_edge_stub.exe`" %1" -force
|
| 225 | ni "$IFEO\ie_to_edge_stub.exe\0" -force >''
|
| 226 | sp "$IFEO\ie_to_edge_stub.exe" 'UseFilter' 1 -type Dword -force
|
| 227 | sp "$IFEO\ie_to_edge_stub.exe\0" 'FilterFullPath' "$DIR\ie_to_edge_stub.exe" -force
|
| 228 | sp "$IFEO\ie_to_edge_stub.exe\0" 'Debugger' "$CMD $DIR\OpenWebSearch.cmd" -force
|
| 229 | ni "$IFEO\msedge.exe\0" -force >''
|
| 230 | sp "$IFEO\msedge.exe" 'UseFilter' 1 -type Dword -force
|
| 231 | sp "$IFEO\msedge.exe\0" 'FilterFullPath' "$MSEP\msedge.exe" -force
|
| 232 | sp "$IFEO\msedge.exe\0" 'Debugger' "$CMD $DIR\OpenWebSearch.cmd" -force
|
| 233 | ## new: automatically re-create the needed hardlink if edge is reinstalled
|
| 234 | $ta = New-ScheduledTaskAction -Execute '%Temp%\OpenWebSearchRepair.cmd'
|
| 235 | $tt = New-ScheduledTaskTrigger -Once -At 00:00; $ts = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries
|
| 236 | Register-ScheduledTask -TaskName 'OpenWebSearchRepair' -Action $ta -Trigger $tt -Settings $ts -RunLevel Highest -Force >''
|
| 237 |
|
| 238 | $OpenWebSearch = @$
|
| 239 | @title OpenWebSearch Redux & echo off & set ?= open start menu web search, widgets links or help in your chosen browser - by AveYo
|
| 240 | for /f %%E in ('"prompt $E$S& for %%e in (1) do rem"') do echo;%%E[2t 2>nul & rem AveYo: minimize prompt
|
| 241 | call :reg_var "HKCU\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice" ProgID ProgID
|
| 242 | if /i "%ProgID%" equ "MSEdgeHTM" echo;Default browser is set to Edge! Change it or remove OpenWebSearch script. & pause & exit /b
|
| 243 | call :reg_var "HKCR\%ProgID%\shell\open\command" "" Browser
|
| 244 | set Choice=& for %%. in (%Browser%) do if not defined Choice set "Choice=%%~."
|
| 245 | call :reg_var "HKCR\MSEdgeMHT\shell\open\command" "" FallBack
|
| 246 | set "Edge=" & for %%. in (%FallBack%) do if not defined Edge set "Edge=%%~."
|
| 247 | set "URI=" & set "URL=" & set "NOOP=" & set "PassTrough=%Edge:msedge=edge%"
|
| 248 | set "CLI=%CMDCMDLINE:"=``% "
|
| 249 | if defined CLI set "CLI=%CLI:*ie_to_edge_stub.exe`` =%"
|
| 250 | if defined CLI set "CLI=%CLI:*ie_to_edge_stub.exe =%"
|
| 251 | if defined CLI set "CLI=%CLI:*msedge.exe`` =%"
|
| 252 | if defined CLI set "CLI=%CLI:*msedge.exe =%"
|
| 253 | set "FIX=%CLI:~-1%"
|
| 254 | if defined CLI if "%FIX%"==" " set "CLI=%CLI:~0,-1%"
|
| 255 | if defined CLI set "RED=%CLI:microsoft-edge=%"
|
| 256 | if defined CLI set "URL=%CLI:http=%"
|
| 257 | if defined CLI set "ARG=%CLI:``="%"
|
| 258 | if "%CLI%" equ "%RED%" (set NOOP=1) else if "%CLI%" equ "%URL%" (set NOOP=1)
|
| 259 | if defined NOOP if not exist "%PassTrough%" echo;@mklink /h "%PassTrough%" "%Edge%" >"%Temp%\OpenWebSearchRepair.cmd"
|
| 260 | if defined NOOP if not exist "%PassTrough%" schtasks /run /tn OpenWebSearchRepair 2>nul >nul
|
| 261 | if defined NOOP if not exist "%PassTrough%" timeout /t 3 >nul
|
| 262 | if defined NOOP if exist "%PassTrough%" start "" "%PassTrough%" %ARG%
|
| 263 | if defined NOOP exit /b
|
| 264 | set "URL=%CLI:*microsoft-edge=%"
|
| 265 | set "URL=http%URL:*http=%"
|
| 266 | set "FIX=%URL:~-2%"
|
| 267 | if defined URL if "%FIX%"=="``" set "URL=%URL:~0,-2%"
|
| 268 | call :dec_url
|
| 269 | start "" "%Choice%" "%URL%"
|
| 270 | exit
|
| 271 |
|
| 272 | :reg_var [USAGE] call :reg_var "HKCU\Volatile Environment" value-or-"" variable [extra options]
|
| 273 | set {var}=& set {reg}=reg query "%~1" /v %2 /z /se "," /f /e& if %2=="" set {reg}=reg query "%~1" /ve /z /se "," /f /e
|
| 274 | for /f "skip=2 tokens=* delims=" %%V in ('%{reg}% %4 %5 %6 %7 %8 %9 2^>nul') do if not defined {var} set "{var}=%%V"
|
| 275 | if not defined {var} (set {reg}=& set "%~3="& exit /b) else if %2=="" set "{var}=%{var}:*) =%"& rem AveYo: v3
|
| 276 | if not defined {var} (set {reg}=& set "%~3="& exit /b) else set {reg}=& set "%~3=%{var}:*) =%"& set {var}=& exit /b
|
| 277 |
|
| 278 | :dec_url brute url percent decoding by AveYo
|
| 279 | set ".=%URL:!=}%"&setlocal enabledelayedexpansion& rem brute url percent decoding
|
| 280 | set ".=!.:%%={!" &set ".=!.:{3A=:!" &set ".=!.:{2F=/!" &set ".=!.:{3F=?!" &set ".=!.:{23=#!" &set ".=!.:{5B=[!" &set ".=!.:{5D=]!"
|
| 281 | set ".=!.:{40=@!"&set ".=!.:{21=}!" &set ".=!.:{24=$!" &set ".=!.:{26=&!" &set ".=!.:{27='!" &set ".=!.:{28=(!" &set ".=!.:{29=)!"
|
| 282 | set ".=!.:{2A=*!"&set ".=!.:{2B=+!" &set ".=!.:{2C=,!" &set ".=!.:{3B=;!" &set ".=!.:{3D==!" &set ".=!.:{25=%%!"&set ".=!.:{20= !"
|
| 283 | set ".=!.:{=%%!" &rem set ",=!.:%%=!" & if "!,!" neq "!.!" endlocal& set "URL=%.:}=!%" & call :dec_url
|
| 284 | endlocal& set "URL=%.:}=!%" & exit /b
|
| 285 | rem done
|
| 286 |
|
| 287 | $@
|
| 288 | [io.file]::WriteAllText("$DIR\OpenWebSearch.cmd", $OpenWebSearch)
|
| 289 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 290 |
|
| 291 | ## 8 done
|
| 292 | $done = gp 'Registry::HKEY_Users\S-1-5-21*\Volatile*' Edge_Removal -ea 0; if ($done) {rp $done.PSPath Edge_Removal -force -ea 0}
|
| 293 | if ((get-process -name 'explorer' -ea 0) -eq $null) {start explorer}
|
| 294 |
|
| 295 | ## bonus enter into powershell console: firefox / edge / webview to install a browser / reinstall edge or webview after removal
|
| 296 | ${.} = [char]27; $firefox = "${.}[38;2;255;165;0m firefox"; $reinstall = "${.}[96m edge / webview / xsocial${.}[97m "
|
| 297 | write-host "`n${.}[40;32m EDGE REMOVED! ${.}[97m -GET-ANOTHER-BROWSER? ENTER:$firefox ${.}[97m -REINSTALL? ENTER:$reinstall"
|
| 298 | ## -------------------------------------------------------------------------------------------------------------------------------
|
| 299 |
|
| 300 | ## 0 ask to run script as admin
|
| 301 | '@.replace("$@","'@").replace("@$","@'") -force -ea 0; $code='gp ''Registry::HKEY_Users\S-1-5-21*\Volatile*'' Edge_Removal -ea 0'
|
| 302 | start powershell -args "-nop -noe -c & {iex(($code)[0].Edge_Removal)}" -verb runas
|
| 303 | $_Press_Enter
|
| 304 | #::
|
| 305 |
|