Powershell: Uninstall problem(context menu was not removed)

Created on 20 Sep 2018  ·  11Comments  ·  Source: PowerShell/PowerShell

Steps to reproduce

uninstall the previous version powershell6-preview

Expected behavior

delete the folder and context menu at the same time

Actual behavior

folder was deleted, but the context menu not

Environment data

I do not remember the version number since I have uninstalled it.
But I have the package name PowerShell-6.1.0-rc.1-win-x64.msi which used to install previous version.

image

Area-Maintainers-Build

Most helpful comment

After installing PowerShell-7.0.0-win-x64.msi, the PowerShell preview 7.0 was uninstalled, but the context menu was kept.
image
Then I removed the context menu "PowerShell 7-preview" by Easy Context Menu 1.6.

All 11 comments

I have this problem on my machine as well. It seems there must've been a faulty MSI during a preview phases when the 6.1-preview packages were renamed to 6-preview. 6.1.0 correctly removes the context menu on uninstall. Since this is a preview build, I'd advise to manually remove the left-over registry keys, you can find them here

I also have been dealing with this for months. Wish someone would whip up a quick tool to automate this as it's very annoying for hundreds of people to have to go to their registry to fully remove a program.

Edit: got it all fixed up and it wasn't that bad

PR #8496 has been made to fix this, can you report which version. Otherwise this is just the nature of previews that some previews might have bugs in them (I saw it generally working but there were some 'bad' versions in the past that caused that). Windows 1903 added a feature called 'Sandbox' if you want to try out previews without affecting your system or having to do it in a virtual machine

I saw a similar problem when upgrading from 6.2.0 to 7.0.0-preview.1:

  1. Install PowerShell-6.2.0-win-x64.msi
  2. Install PowerShell-7.0.0-preview.1-win-x64.msi
  3. Uninstall 6.2.0
  4. Repair 7.0.0-preview.1, just in case the uninstallation of 6.2.0 damaged it

After those steps, I had duplicate registry keys, e.g. HKEY_LOCAL_MACHINE\SOFTWARE\Classes\DesktopBackground\Shell\PowerShell6x64 and HKEY_LOCAL_MACHINE\SOFTWARE\Classes\DesktopBackground\Shell\PowerShell7-previewx64. The PowerShell6x64 keys ought to have been deleted. I presume Windows Installer did not delete them because the component GUID was not changed.

This comment says PowerShell intends to switch from MSI to MSIX instead of frobbing the component GUIDs. Is that still going to happen before the 7.0.0 release?

(By the way, I spent a while searching docs.microsoft.com for information on the HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\ContextMenus key. However, it turns out to be referenced by ExtendedSubCommandsKey values of other Registry keys, rather than specially recognized by the shell.)

@bergmeister After uninstalling PowerShell-7.0.0-preview.2-win-x86.msi I am left with a broken PowerShell 7-preview (x86) menu; it seems #8496 did not fix this issue.

After installing PowerShell-7.0.0-preview.3-win-x64.msi, the previous preview context menu looks weird. And I have checked the C:\Program Files\PowerShell\6-preview, it might empty by the Powershell7-preview installer.
https://github.com/PowerShell/PowerShell/issues/7826#issuecomment-525013525
image

11png

uninstalled 6 and 7-preview, looks awful...

Please refer to this comment for manually removing left-overs https://github.com/PowerShell/PowerShell/issues/12105#issuecomment-598486477
In issue #12011 a potential solution to this is being discussed.

@bergmeister still there, need reboot?

PS C:\WINDOWS\system32> $version = '7-previewx64'
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\shell\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Drive\shell\PowerShell$version"
WhatIf: 正在目标“项: HKEY_CLASSES_ROOT\Directory\shell\PowerShell7-previewx64”上执行操作“删除键”。
WhatIf: 正在目标“项: HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell7-previewx64”上执行操作“删除键”。
Remove-Item : 找不到路径“HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell7-previewx64”,因为该路径不存在。
所在位置 行:1 字符: 1
+ Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_CLASSES_RO...ell7-previewx64:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

WhatIf: 正在目标“项: HKEY_CLASSES_ROOT\Drive\shell\PowerShell7-previewx64”上执行操作“删除键”。
PS C:\WINDOWS\system32> $version = '6'
PS C:\WINDOWS\system32> Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\shell\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell$version",
>>                              "registry::HKEY_CLASSES_ROOT\Drive\shell\PowerShell$version"
Remove-Item : 找不到路径“HKEY_CLASSES_ROOT\Directory\shell\PowerShell6”,因为该路径不存在。
所在位置 行:1 字符: 1
+ Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_CLASSES_RO...ell\PowerShell6:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Remove-Item : 找不到路径“HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell6”,因为该路径不存在。
所在位置 行:1 字符: 1
+ Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_CLASSES_RO...nus\PowerShell6:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Remove-Item : 找不到路径“HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell6”,因为该路径不存在。
所在位置 行:1 字符: 1
+ Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_CLASSES_RO...ell\PowerShell6:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Remove-Item : 找不到路径“HKEY_CLASSES_ROOT\Drive\shell\PowerShell6”,因为该路径不存在。
所在位置 行:1 字符: 1
+ Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_CLASSES_RO...ell\PowerShell6:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

@maicWorkGithub You could try to remove the context menu by Easy Context Menu 1.6.
image
select the context menu you want to remove, and click delete
image

After installing PowerShell-7.0.0-win-x64.msi, the PowerShell preview 7.0 was uninstalled, but the context menu was kept.
image
Then I removed the context menu "PowerShell 7-preview" by Easy Context Menu 1.6.

Was this page helpful?
0 / 5 - 0 ratings