I uninstalled PowerShell Preview via the control panel.
However it seems to not have uninstalled properly.
As you can see powershell preview is still there when I right click.
Any advice how to get rid of this and/or prevent this issue?
Don't know what caused it or how to prevent it (see @heaths' comment below), but you can remove the context-menu entries as follows (_update_: now perform a _search_ for all relevant keys):
# MUST BE RUN FROM AN ELEVATED CONSOLE.
# Target version whose context menus to remove.
# Use the version suffix as it appears in the shortcut menus,
# and append the bitness of the installation ('x64' vs. 'x86' (32-bit))
$version = '7-previewx64'
# Find all relevant key paths.
$keyPaths = @(
reg query HKEY_CLASSES_ROOT /s /k /e /f "PowerShell$version" |
Select-Object -SkipLast 1
) -ne '' -replace '^', 'registry::'
Remove-Item -Recurse $keyPaths -WhatIf
-WhatIf
previews what would get deleted; remove it once you're confident the right keys are being targeted.
@YMba9g8j9CJp0wLoQf5y
Please provide the system environment information, as this is very helpful!
Now that PowerShell 7 is GA, there's no need to install back the any of the PowerShell 7 RC's.
The next Preview coming out is PowerShell 7.1 which, I think will be coming soon.
Better off doing a uninstall of the PowerShell Preview and everything should be OK.
@MaximoTrinidad, note the premise of this issue:
I uninstalled PowerShell Preview via the control panel.
However it seems to not have uninstalled properly.
@mklement0
I keep forgetting to mention that I manually clean up any left-over folders after the uninstall process. It seems to work for me.
:)
/cc @heaths @bergmeister
System information as requested:
$> Get-ComputerInfo
WindowsBuildLabEx : 18362.1.amd64fre.19h1_release.190318-1202
WindowsCurrentVersion : 6.3
WindowsEditionId : Professional
WindowsInstallationType : Client
WindowsInstallDateFromRegistry : 6/20/2019 12:19:13 PM
WindowsProductId : 00331-10000-00001-AA213
WindowsProductName : Windows 10 Pro
WindowsRegisteredOrganization :
WindowsRegisteredOwner : admin
WindowsSystemRoot : C:\Windows
WindowsVersion : 1909
WindowsUBR : 719
BiosCharacteristics : {7, 11, 12, 15鈥
BiosBIOSVersion : {ALASKA - 1072009, 1.50, American Megatrends - 5000D}
BiosBuildNumber :
BiosCaption : 1.50
BiosCodeSet :
BiosCurrentLanguage :
BiosDescription : 1.50
BiosEmbeddedControllerMajorVersion : 255
BiosEmbeddedControllerMinorVersion : 255
BiosFirmwareType : Uefi
BiosIdentificationCode :
BiosInstallableLanguages :
BiosInstallDate :
BiosLanguageEdition :
BiosListOfLanguages :
BiosManufacturer : American Megatrends Inc.
BiosName : 1.50
BiosOtherTargetOS :
BiosPrimaryBIOS : True
BiosReleaseDate : 1/24/2019 7:00:00 PM
BiosSerialNumber : To be filled by O.E.M.
BiosSMBIOSBIOSVersion : 1.50
BiosSMBIOSMajorVersion : 2
BiosSMBIOSMinorVersion : 8
BiosSMBIOSPresent : True
BiosSoftwareElementState : Running
BiosStatus : OK
BiosSystemBiosMajorVersion : 5
BiosSystemBiosMinorVersion : 13
BiosTargetOperatingSystem : 0
BiosVersion : ALASKA - 1072009
CsAdminPasswordStatus : Unknown
CsAutomaticManagedPagefile : True
CsAutomaticResetBootOption : True
CsAutomaticResetCapability : True
CsBootOptionOnLimit :
CsBootOptionOnWatchDog :
CsBootROMSupported : True
CsBootStatus : {0, 0, 0, 0鈥
CsBootupState : Normal boot
CsCaption : MSDN-JPR-DEV
CsChassisBootupState : Safe
CsChassisSKUNumber : To be filled by O.E.M.
CsCurrentTimeZone : -240
CsDaylightInEffect : True
CsDescription : AT/AT COMPATIBLE
CsDNSHostName : MSDN-jpr-dev
CsDomain : amd.com
CsDomainRole : MemberWorkstation
CsEnableDaylightSavingsTime : True
CsFrontPanelResetStatus : Unknown
CsHypervisorPresent : False
CsInfraredSupported : False
CsInitialLoadInfo :
CsInstallDate :
CsKeyboardPasswordStatus : Unknown
CsLastLoadInfo :
CsManufacturer : Micro-Star International Co., Ltd
CsModel : MS-7B86
CsName : MSDN-JPR-DEV
CsNetworkAdapters : {Ethernet}
CsNetworkServerModeEnabled : True
CsNumberOfLogicalProcessors : 16
CsNumberOfProcessors : 1
CsProcessors : {AMD Ryzen 7 2700X Eight-Core Processor }
CsOEMStringArray : {To be filled by O.E.M.}
CsPartOfDomain : True
CsPauseAfterReset : -1
CsPCSystemType : Desktop
CsPCSystemTypeEx : Desktop
CsPowerManagementCapabilities :
CsPowerManagementSupported :
CsPowerOnPasswordStatus : Unknown
CsPowerState : Unknown
CsPowerSupplyState : Safe
CsPrimaryOwnerContact :
CsPrimaryOwnerName : admin
CsResetCapability : Other
CsResetCount : -1
CsResetLimit : -1
CsRoles : {LM_Workstation, LM_Server, NT}
CsStatus : OK
CsSupportContactDescription :
CsSystemFamily : To be filled by O.E.M.
CsSystemSKUNumber : To be filled by O.E.M.
CsSystemType : x64-based PC
CsThermalState : Safe
CsTotalPhysicalMemory : 17128251392
CsPhysicallyInstalledMemory : 16777216
CsWakeUpType : PowerSwitch
CsWorkgroup :
OsName : Microsoft Windows 10 Pro
OsType : WINNT
OsOperatingSystemSKU : 48
OsVersion : 10.0.18363
OsCSDVersion :
OsBuildNumber : 18363
OsHotFixes : {KB4534132, KB4497727, KB4498523, KB4503308鈥
OsBootDevice : \Device\HarddiskVolume2
OsSystemDevice : \Device\HarddiskVolume4
OsSystemDirectory : C:\Windows\system32
OsSystemDrive : C:
OsWindowsDirectory : C:\Windows
OsCountryCode : 1
OsCurrentTimeZone : -300
OsLocaleID : 0409
OsLocale : en-US
OsLocalDateTime : 3/12/2020 12:01:41 PM
OsLastBootUpTime : 3/11/2020 10:31:02 PM
OsUptime : 13:30:38.9899546
OsBuildType : Multiprocessor Free
OsCodeSet : 1252
OsDataExecutionPreventionAvailable : True
OsDataExecutionPrevention32BitApplications : True
OsDataExecutionPreventionDrivers : True
OsDataExecutionPreventionSupportPolicy : OptIn
OsDebug : False
OsDistributed : False
OsEncryptionLevel : 256
OsForegroundApplicationBoost : Maximum
OsTotalVisibleMemorySize : 16726808
OsFreePhysicalMemory : 8532120
OsTotalVirtualMemorySize : 19217176
OsFreeVirtualMemory : 5415952
OsInUseVirtualMemory : 13801224
OsTotalSwapSpaceSize :
OsSizeStoredInPagingFiles : 2490368
OsFreeSpaceInPagingFiles : 2419676
OsPagingFiles : {C:\pagefile.sys}
OsHardwareAbstractionLayer : 10.0.18362.628
OsInstallDate : 6/20/2019 8:19:13 AM
OsManufacturer : Microsoft Corporation
OsMaxNumberOfProcesses : 4294967295
OsMaxProcessMemorySize : 137438953344
OsMuiLanguages : {en-US}
OsNumberOfLicensedUsers :
OsNumberOfProcesses : 206
OsNumberOfUsers : 7
OsOrganization :
OsArchitecture : 64-bit
OsLanguage : en-US
OsProductSuites : {TerminalServicesSingleSession}
OsOtherTypeDescription :
OsPAEEnabled :
OsPortableOperatingSystem : False
OsPrimary : True
OsProductType : WorkStation
OsRegisteredUser : admin
OsSerialNumber : 00331-10000-00001-AA213
OsServicePackMajorVersion : 0
OsServicePackMinorVersion : 0
OsStatus : OK
OsSuites : {TerminalServices, TerminalServicesSingleSession}
OsServerLevel :
KeyboardLayout : en-US
TimeZone : (UTC-05:00) Eastern Time (US & Canada)
LogonServer : \\SBOSDCP09
PowerPlatformRole : Desktop
HyperVisorPresent : False
HyperVRequirementDataExecutionPreventionAvailable : True
HyperVRequirementSecondLevelAddressTranslation : True
HyperVRequirementVirtualizationFirmwareEnabled : False
HyperVRequirementVMMonitorModeExtensions : True
DeviceGuardSmartStatus : Off
DeviceGuardRequiredSecurityProperties :
DeviceGuardAvailableSecurityProperties :
DeviceGuardSecurityServicesConfigured :
DeviceGuardSecurityServicesRunning :
DeviceGuardCodeIntegrityPolicyEnforcementStatus :
DeviceGuardUserModeCodeIntegrityPolicyEnforcementStatus :
Right-click on it and go to the shortcut location, if you even get the option. If not, it's a visual cache issue that sometimes happen with Windows. Or did you by chance create this shortcut yourself, or customize console host setings (font, buffer size, etc.)? That will also create a user shortcut (replaces .pif files from old that will not be cleaned up (no way for Windows Installer to track it).
This is what happens when I try to use the shorcut.
I didn't create the shortcut myself. I don't think I customized anything.
@heaths, I think you're thinking about a _taskbar_ icon's context menu, whereas @YMba9g8j9CJp0wLoQf5y is talking about a File Explorer / Desktop folder's shortcut menu.
@YMba9g8j9CJp0wLoQf5y, can you confirm?
I'm not clear on the exact terminology but I believe I'm talking about the File Explorer / Desktop folder's shortcut menu.
IE I open up a folder in explorer and right click on it:
Yes, that's what I meant - these entries there are controlled via registry entries, not shortcut files, hence my manual removal commands above.
Okay. Likely because the component GUIDs were changed. This affects ref-counting components. I'll be rescheduling RemoveExistingProducts
which will fix a lot of these issues as well. (Generally, don't hardcode component GUIDs unless you have to with WiX 3.10 and newer.)
Cool!
I was able to reproduce the issue on a clean VM.
Install PowerShell-7.0.0-rc.3-win-x64.msi
Install PowerShell-7.0.0-win-x64.msi
All short-cuts icons show up fine.
Uninstall from Control Panel: PowerShell-7.0.0-rc.3
** Follow by a system restart **
The PowerShell Preview shortcut is not removed.
Now I understand the work-around, to remove manually the entries from the registry:
manual removal commands
Here's the image of the registry after the uninstall of the PowerShell Preview:
Now, If I run the installation of PowerShell Preview again, I get back the shortcut to work.
Thanks, @mklement0
I've removed the registry entries but the invalid shortcut still exists
Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\shell\PowerShell$version", "registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell$version","registry::HKEY_CLASSES_ROOT\Drive\shell\PowerShell$version"
Remove-Item: Cannot find path 'HKEY_CLASSES_ROOT\Directory\shell\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'HKEY_CLASSES_ROOT\Drive\shell\PowerShell7-previewx64' because it does not exist.
@YMba9g8j9CJp0wLoQf5y, did you perhaps have the 32-bit version installed? Try $version = '7-previewx86
in that case.
If you use regedit.exe
to navigate to HKEY_CLASSES_ROOT\Directory\shell
, what PowerShell-related subkeys do you see there?
@YMba9g8j9CJp0wLoQf5y
Make sure to start with:
$version = '7-previewx64'
Remove-Item -WhatIf -Recurse "registry::HKEY_CLASSES_ROOT\Directory\shell\PowerShell$version",
"registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell$version",
"registry::HKEY_CLASSES_ROOT\Drive\shell\PowerShell$version";
Now, the above command should work in the sense that it found the registry entries.
Make sure to remove the "_-WhatIf_" parameter to truly remove the registry entries. The "WhatIf" is use to verify is the command work before doing a commit.
It should work!
@MaximoTrinidad, the output in @YMba9g8j9CJp0wLoQf5y's previous comment shows that the targeted registry keys _don't exist_, which even -WhatIf
will tell you.
One important aspect is: if the preview version was installed as a _32-bit_ version, then changing to $version = '7-previewx86
- if that is indeed the naming convention used for it, I'm not sure - would only be effective if you ran the removal commands too from a _32-bit_ PowerShell session.
The alternative is to run from a 64-bit process, but target HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes
instead.
Apologies for the confusion originally I did run the command and the registry entries did exist and showed up with the -WhatIf.
I just didn't save a screenshot of those entries showing up and ended up showing without the -WhatIf to show the entries are no longer there.
I definitely didn't install 32 bit versions of anything.
Thanks for clarifying, @YMba9g8j9CJp0wLoQf5y. This takes us back to:
If you use
regedit.exe
to navigate toHKEY_CLASSES_ROOT\Directory\shell
, what PowerShell-related subkeys do you see there?
I can't use regedit on my computer. Is there another way to get the info you need?
Try Get-ChildItem registry::HKEY_CLASSES_ROOT\Directory\shell
Hive: HKEY_CLASSES_ROOT\Directory\shell
Name Property
---- --------
AnyCode (default) : @C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\1033\\VSLauncherUI.dll,-1002
cmd (default) : @shell32.dll,-8506
Extended :
HideBasedOnVelocityId : 6527944
NoWorkingDirectory :
find LegacyDisable :
SuppressionPolicy : 128
git_gui (default) : Git &GUI Here
Icon : C:\Program Files\Git\cmd\git-gui.exe
git_shell (default) : Git Ba&sh Here
Icon : C:\Program Files\Git\git-bash.exe
Powershell (default) : @shell32.dll,-8508
Extended :
NoWorkingDirectory :
ShowBasedOnVelocityId : 6527944
PowerShell7x64 MUIVerb : &PowerShell 7
Icon : C:\Program Files\PowerShell\7\assets\Powershell_black.ico
ExtendedSubCommandsKey : Directory\ContextMenus\PowerShell7x64
psdbsvn (default) : Launch PSDB for SVN
UpdateEncryptionSettings AppliesTo : System.StorageProviderId:<>"network" AND
System.StorageProviderProtectionMode:<>1 AND System.StorageProviderProtectionMode:<>2
AttributeMask : 8192
AttributeValue : 8192
ExtendedSubCommandsKey : Directory\shell\UpdateEncryptionSettings
ImpliedSelectionModel : 0
MUIVerb : @efscore.dll,-101
MultiSelectModel : Player
Position : Bottom
VSCode (default) : Open w&ith Code
Icon : C:\Users\juaramos\AppData\Local\Programs\Microsoft VS Code\Code.exe
WSL (default) : @wsl.exe,-2
Extended :
NoWorkingDirectory :
Nothing out of the ordinary there. Now repeat for registry::HKEY_CLASSES_ROOT\Directory\ContextMenus
and
registry::HKEY_CLASSES_ROOT\Drive\shell
and see if you find any -preview
references there.
Gotcha. Just ran those commands. But nothing with -preview came up.
HKEY_CLASSES_ROOT has different 32- and 64-bit views. Depending on your bitness of PowerShell, you will get one view or another. This is why I generally have customers use reg.exe, which lets you specify which bitness you want. With PowerShell, use x64 which can view both the 32- and 64-bit views, but you'll need to go to HKEY_LOCAL_MACHINESoftwareWow6432nodeClasses instead if you want the 32-bit view.
@heaths, the bitness issue was covered before, and @YMba9g8j9CJp0wLoQf5y has assured us that no funny 32-bit business is involved - though it is good to know that reg.exe
can target both 32-bit and 64-bit hives with /reg:32
and /reg:64
.
@YMba9g8j9CJp0wLoQf5y, this leaves me with: Have you tried turning it off and on again?
Note also that this is a dup of #12011, which I'm working on fixing now. The component GUIDs and upgrade information are not properly authored. Basically, you shouldn't hardcode GUIDs except in rare cases. WiX will do the right thing when authored propertly (I'm was a dev on WiX for many years).
In this specific case, the same component GUID was used in the Windows Installer packages, which creates a shared component that gets ref-counted. Registry keys aren't removed until the ref-count hits (or would hit, rather) 0. That will leave registry information behind. On top of that, the disparate registry values get orphaned when their last package that wrote them is removed, so even removing other versions that ref-counted the shared component but have different keys will leave them behind.
This is one specific reason why you shouldn't hard-code component GUIDs.
I have restarted my computer multiple times @mklement0
One thing. Weirdly enough this issue only occurs if I click on an empty space.
If I click on a folder it works fine.
Oops! I forgot HKEY_CLASSES_ROOT\Directory\Background\shell
in my manual removal command - please see the update.
Hi @mklement0
The HKEY_CLASSES_ROOT\DesktopBackground\shell\PowerShell7-previewx64
should also be removed.
Thanks, @b10102016; indeed, and there's even another one (HKEY_CLASSES_ROOT\LibraryFolder\background\shell
).
I've switched the above manual removal command to a reg.exe query
-based approach that finds all relevant keys.
I just tried the new removal command and restarted my computer but I still have the issue.
@YMba9g8j9CJp0wLoQf5y, and the following produces no output?
reg query HKEY_CLASSES_ROOT /s /k /e /f "PowerShell7-previewx64"
Couldn't tell ya.
$> reg query HKEY_CLASSES_ROOT /s /k /e /f "PowerShell7-previewx64"
ERROR: Registry editing has been disabled by your administrator.
@YMba9g8j9CJp0wLoQf5y:
If you can't run this command, you couldn't possibly have successfully removed the keys with the removal commands, given that that command is part of the latter.
Make sure that you run the commands _as an administrator_.
And, generally, please be more specific up-front about what actually happened when you say things like "I just tried the new removal command" and things didn't work as expected.
I did run it as administrator.
The IT at work just disables registry editing.
Apologies.
If you're at least able to run Remove-Item
as admin, then try to use the following, explicit list of key paths (obtained with the reg query
command):
$keyPaths =
'registry::HKEY_CLASSES_ROOT\DesktopBackground\Shell\PowerShell7-previewx64',
'registry::HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell7-previewx64',
'registry::HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell7-previewx64',
'registry::HKEY_CLASSES_ROOT\Directory\shell\PowerShell7-previewx64',
'registry::HKEY_CLASSES_ROOT\Drive\shell\PowerShell7-previewx64',
'registry::HKEY_CLASSES_ROOT\LibraryFolder\background\shell\PowerShell7-previewx64'
> $keyPaths =
>> 'HKEY_CLASSES_ROOT\DesktopBackground\Shell\PowerShell7-previewx64',
>> 'HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell7-previewx64',
>> 'HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell7-previewx64',
>> 'HKEY_CLASSES_ROOT\Directory\shell\PowerShell7-previewx64',
>> 'HKEY_CLASSES_ROOT\Drive\shell\PowerShell7-previewx64',
>> 'HKEY_CLASSES_ROOT\LibraryFolder\background\shell\PowerShell7-previewx64'
Remove-Item $keyPaths
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\DesktopBackground\Shell\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\Directory\ContextMenus\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\Directory\shell\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\Drive\shell\PowerShell7-previewx64' because it does not exist.
Remove-Item: Cannot find path 'C:\Users\YMba9g8j9CJp0wLoQf5y\Desktop\HKEY_CLASSES_ROOT\LibraryFolder\background\shell\PowerShell7-previewx64' because it does not exist.
@YMba9g8j9CJp0wLoQf5y, sorry - had forgotten the registry::
provider prefix - please see the since-updated previous comment.
That fixed it :)
Thank you very much @mklement0 for your patience 馃憤
Is there any way to prevent this issue in the future?
We will get updated MSI in next month.
Gotcha. I'll close the issue then.
Most helpful comment
Don't know what caused it or how to prevent it(see @heaths' comment below), but you can remove the context-menu entries as follows (_update_: now perform a _search_ for all relevant keys):-WhatIf
previews what would get deleted; remove it once you're confident the right keys are being targeted.