-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
uninstall.ps1
60 lines (51 loc) · 3.32 KB
/
uninstall.ps1
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
#Requires -Version 6
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[ValidateSet('Default', 'Flat', 'Mini')]
[string] $Layout = 'Default',
[Parameter()]
[switch] $PreRelease
)
# Based on @nerdio01's version in https://github.com/microsoft/terminal/issues/1060
if ((Get-Process -Id $pid).Path -like "*WindowsApps*") {
Write-Error "PowerShell installed via Microsoft Store is not supported. Learn other ways to install it from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7 . Exit.";
exit 1
}
if ((Test-Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\MenuTerminal") -and
-not (Test-Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\MenuTerminal")) {
Write-Error "Please execute uninstall.old.ps1 to remove previous installation."
exit 1
}
$localCache = "$Env:LOCALAPPDATA\Microsoft\WindowsApps\Cache"
if (Test-Path $localCache) {
Remove-Item $localCache -Recurse
}
Write-Host "Use" $layout "layout."
if ($layout -eq "Default") {
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\MenuTerminal' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\MenuTerminal' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\ContextMenus\MenuTerminal\shell' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\MenuTerminalAdmin' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\MenuTerminalAdmin' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\ContextMenus\MenuTerminalAdmin\shell' -Recurse -ErrorAction Ignore | Out-Null
} elseif ($layout -eq "Flat") {
$rootKey = 'HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell'
foreach ($key in Get-ChildItem -Path "Registry::$rootKey") {
if (($key.Name -like "$rootKey\MenuTerminal_*") -or ($key.Name -like "$rootKey\MenuTerminalAdmin_*")) {
Remove-Item "Registry::$key" -Recurse -ErrorAction Ignore | Out-Null
}
}
$rootKey = 'HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell'
foreach ($key in Get-ChildItem -Path "Registry::$rootKey") {
if (($key.Name -like "$rootKey\MenuTerminal_*") -or ($key.Name -like "$rootKey\MenuTerminalAdmin_*")) {
Remove-Item "Registry::$key" -Recurse -ErrorAction Ignore | Out-Null
}
}
} elseif ($layout -eq "Mini") {
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\MenuTerminalMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\MenuTerminalAdminMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\MenuTerminalMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\MenuTerminalAdminMini' -Recurse -ErrorAction Ignore | Out-Null
}
Write-Host "Windows Terminal uninstalled from Windows Explorer context menu."