|
1 | 1 | [CmdletBinding()] |
2 | 2 | param ( |
3 | | - [Switch]$Setup |
| 3 | + [Switch]$UninstallAll, |
| 4 | + [Switch]$Exit |
4 | 5 | ) |
5 | 6 |
|
6 | 7 | $ProgressPreference = "SilentlyContinue" |
7 | 8 | $user = $env:USERNAME |
8 | 9 | $SID = (New-Object System.Security.Principal.NTAccount($user)).Translate([Security.Principal.SecurityIdentifier]).Value |
9 | 10 |
|
| 11 | +if ($Exit -and (-not $UninstallAll)) { |
| 12 | + $Exit = $false |
| 13 | +} |
| 14 | + |
10 | 15 | function PauseNul ($message = "Press any key to continue... ") { |
11 | 16 | Write-Host $message -NoNewLine |
12 | 17 | $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') | Out-Null |
@@ -96,51 +101,53 @@ function UninstallAll { |
96 | 101 | } |
97 | 102 | } |
98 | 103 |
|
99 | | -if ($Setup) { |
100 | | - $removeData = $true |
101 | | - $removeWebView = $true |
102 | | - UninstallAll |
103 | | - exit |
104 | | -} |
105 | | - |
106 | 104 | if ($null -ne $(whoami /user | Select-String "S-1-5-18")) { |
107 | 105 | Write-Host "This script can't be ran as TrustedInstaller or SYSTEM." |
108 | 106 | Write-Host "Please relaunch this script under a regular admin account.`n" |
109 | | - PauseNul "Press any key to exit... " |
| 107 | + if (!($Exit)) {PauseNul "Press any key to exit... "} |
110 | 108 | exit 1 |
111 | 109 | } else { |
112 | 110 | if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) { |
113 | 111 | Start-Process PowerShell "-NoProfile -ExecutionPolicy Unrestricted -File `"$PSCommandPath`"" -Verb RunAs; exit |
114 | 112 | } |
115 | 113 | } |
116 | 114 |
|
117 | | -$removeWebView = $false |
118 | | -$removeData = $true |
119 | | -while (!($continue)) { |
120 | | - Clear-Host; Write-Host "This script will remove Microsoft Edge, as once you install it, you can't normally uninstall it. |
121 | | -Major credit to ave9858: https://gist.github.com/ave9858/c3451d9f452389ac7607c99d45edecc6`n" -ForegroundColor Yellow |
| 115 | +if ($Exit) { |
| 116 | + $removeData = $true |
| 117 | + $removeWebView = $true |
| 118 | + UninstallAll |
| 119 | + if ($Exit) {exit} else {} |
| 120 | +} |
122 | 121 |
|
123 | | - if ($removeWebView) {$colourWeb = "Green"; $textWeb = "Selected"} else {$colourWeb = "Red"; $textWeb = "Unselected"} |
124 | | - if ($removeData) {$colourData = "Green"; $textData = "Selected"} else {$colourData = "Red"; $textData = "Unselected"} |
125 | | - |
126 | | - Write-Host "Options:" |
127 | | - Write-Host "[1] Remove Edge WebView ($textWeb)" -ForegroundColor $colourWeb |
128 | | - Write-Host "[2] Remove Edge User Data ($textData)`n" -ForegroundColor $colourData |
129 | | - Write-Host "Press enter to continue or use numbers to select options... " -NoNewLine |
130 | | - |
131 | | - $userInput = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') |
132 | | - |
133 | | - write-host "$input.VirtualKeyCode" |
134 | | - |
135 | | - switch ($userInput.VirtualKeyCode) { |
136 | | - 49 { # num 1 |
137 | | - $removeWebView = !$removeWebView |
138 | | - } |
139 | | - 50 { # num 2 |
140 | | - $removeData = !$removeData |
141 | | - } |
142 | | - 13 { # enter |
143 | | - $continue = $true |
| 122 | +$removeWebView = $true |
| 123 | +$removeData = $true |
| 124 | +if (!($UninstallAll)) { |
| 125 | + while (!($continue)) { |
| 126 | + Clear-Host; Write-Host "This script will remove Microsoft Edge, as once you install it, you can't normally uninstall it. |
| 127 | + Major credit to ave9858: https://gist.github.com/ave9858/c3451d9f452389ac7607c99d45edecc6`n" -ForegroundColor Yellow |
| 128 | + |
| 129 | + if ($removeWebView) {$colourWeb = "Green"; $textWeb = "Selected"} else {$colourWeb = "Red"; $textWeb = "Unselected"} |
| 130 | + if ($removeData) {$colourData = "Green"; $textData = "Selected"} else {$colourData = "Red"; $textData = "Unselected"} |
| 131 | + |
| 132 | + Write-Host "Options:" |
| 133 | + Write-Host "[1] Remove Edge WebView ($textWeb)" -ForegroundColor $colourWeb |
| 134 | + Write-Host "[2] Remove Edge User Data ($textData)`n" -ForegroundColor $colourData |
| 135 | + Write-Host "Press enter to continue or use numbers to select options... " -NoNewLine |
| 136 | + |
| 137 | + $userInput = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') |
| 138 | + |
| 139 | + write-host "$input.VirtualKeyCode" |
| 140 | + |
| 141 | + switch ($userInput.VirtualKeyCode) { |
| 142 | + 49 { # num 1 |
| 143 | + $removeWebView = !$removeWebView |
| 144 | + } |
| 145 | + 50 { # num 2 |
| 146 | + $removeData = !$removeData |
| 147 | + } |
| 148 | + 13 { # enter |
| 149 | + $continue = $true |
| 150 | + } |
144 | 151 | } |
145 | 152 | } |
146 | 153 | } |
|
0 commit comments