-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
uninstall.old.ps1
55 lines (47 loc) · 2.88 KB
/
uninstall.old.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
#Requires -RunAsAdministrator
#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
}
$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_CLASSES_ROOT\Directory\shell\MenuTerminal' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\shell\MenuTerminalAdmin' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminalAdmin' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminalAdmin\shell' -Recurse -ErrorAction Ignore | Out-Null
} elseif ($layout -eq "Flat") {
$rootKey = 'HKEY_CLASSES_ROOT\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_CLASSES_ROOT\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_CLASSES_ROOT\Directory\shell\MenuTerminalMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\shell\MenuTerminalAdminMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminalMini' -Recurse -ErrorAction Ignore | Out-Null
Remove-Item -Path 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminalAdminMini' -Recurse -ErrorAction Ignore | Out-Null
}
Write-Host "Windows Terminal uninstalled from Windows Explorer context menu."