Windows 10 22H2 19045.3086
With Shift + Right-click, I get a "Open PowerShell window here" entry in the context menu. I think I didn't manually add this entry, it's either enabled by some checkbox or came with windows by default.
Today it stopped working. When I click it, I get this error:
Application not found
The registry entries Computer\HKEY_CLASSES_ROOT\Directory\shell\Powershell\command and Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command do not contain a full path, they are both set to
powershell.exe -noexit -command Set-Location -literalPath '%V'
I can not modify them to contain a full path, regedit (running as administrator) gives the error Cannot edit : Error writing the value's new contents if I attempt to change them.
From a Command Prompt, while in any folder, I can just start powershell and it loads up fine. echo %PATH% also shows that C:\Windows\System32\WindowsPowerShell\v1.0\ is part of my path. Using Process Explorer, I can also see that it is in the PATH variable in the explorer.exe's environment.
Why does this error occur, how can I fix it?
Edit: sfc /scannow didn't fix it, rebooting didn't fix it, Windows updates are "up to date".
Edit 2: I ran Process Monitor while clicking on "Open PowerShell window here", and filtered the events to those that were not successful and contained "powershell". I don't know which of these should fail and which shouldn't, though.
"FASTIO_NETWORK_QUERY_OPEN","C:\Windows\System32\powershell.exe","FAST IO DISALLOWED","","File System",""
"FASTIO_NETWORK_QUERY_OPEN","C:\Windows\powershell.exe","FAST IO DISALLOWED","","File System",""
"IRP_MJ_CREATE","C:\Windows\System32\powershell.exe","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a","File System",""
"IRP_MJ_CREATE","C:\Windows\powershell.exe","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a","File System",""
"RegOpenKey","HKCR\.cdxml\Microsoft.PowerShellCmdletDefinitionXML.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.ps1\Microsoft.PowerShellScript.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.ps1xml\Microsoft.PowerShellXMLData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.psc1\Microsoft.PowerShellConsole.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.psd1\Microsoft.PowerShellData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.psm1\Microsoft.PowerShellModule.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\.pssc\Microsoft.PowerShellSessionConfiguration.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCR\Directory\background\shell\Powershell\DropTarget","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellCmdletDefinitionXML.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellConsole.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellData.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellModule.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellScript.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellSessionConfiguration.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCR\Microsoft.PowerShellXMLData.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\.cdxml\Microsoft.PowerShellCmdletDefinitionXML.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.ps1\Microsoft.PowerShellScript.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.ps1xml\Microsoft.PowerShellXMLData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.psc1\Microsoft.PowerShellConsole.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.psd1\Microsoft.PowerShellData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.psm1\Microsoft.PowerShellModule.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\.pssc\Microsoft.PowerShellSessionConfiguration.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\Background\shell\Powershell","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell","NAME NOT FOUND","Desired Access: Maximum Allowed","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell","NAME NOT FOUND","Desired Access: Query Value, Enumerate Sub Keys","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell\DropTarget","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell\command","NAME NOT FOUND","Desired Access: Maximum Allowed","Registry",""
"RegOpenKey","HKCU\Software\Classes\Directory\background\shell\Powershell\command","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellCmdletDefinitionXML.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellConsole.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellData.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellModule.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellScript.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellSessionConfiguration.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Classes\Microsoft.PowerShellXMLData.1\CLSID","NAME NOT FOUND","Desired Access: Query Value","Registry",""
"RegOpenKey","HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\powershell.exe","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.cdxml\Microsoft.PowerShellCmdletDefinitionXML.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.ps1\Microsoft.PowerShellScript.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.ps1xml\Microsoft.PowerShellXMLData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.psc1\Microsoft.PowerShellConsole.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.psd1\Microsoft.PowerShellData.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.psm1\Microsoft.PowerShellModule.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\.pssc\Microsoft.PowerShellSessionConfiguration.1","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\SOFTWARE\Classes\Directory\background\shell\Powershell\DropTarget","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\Software\Microsoft\Windows\CurrentVersion\App Paths\powershell.exe","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\Software\Microsoft\Windows\CurrentVersion\App Paths\powershell.exe","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellCmdletDefinitionXML.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellConsole.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellData.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellModule.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellScript.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellSessionConfiguration.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\Microsoft.PowerShellXMLData.1\CLSID","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\powershell.exe","NAME NOT FOUND","Desired Access: Read","Registry",""
"RegQueryKey","HKCR\Directory\background\shell\Powershell","BUFFER TOO SMALL","Query: Name, Length: 0","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ActivationModel","NAME NOT FOUND","Length: 32","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\AppliesTo","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\CheckSupportedTypes","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\CommandFlags","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\CommandStateHandler","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\CurrentFolderAsSelection","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\DownloadInvokeDisabled","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ExplorerCommandHandler","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ExplorerCommandHandler","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ExtendedSubCommandsKey","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\FolderHandler","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\FriendlyAppName","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\HasLUAShield","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\HideBasedOnVelocityID","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\Icon","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ImpliedSelectionModel","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ImpliedSelectionModel","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\InvokeCommandOnSelection","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\IsInContextMenu","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\LegacyDisable","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\MUIVerb","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\MaxDownloadFileSize","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\MultiSelectModel","NAME NOT FOUND","Length: 60","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\NoSmartScreen","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\OnlyInBrowserWindow","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\OnlyInTabWindow","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\OpenControlPanel","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\OpenControlPanelPage","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\PaneVisibleProperty","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\Position","NAME NOT FOUND","Length: 140","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ProgrammaticAccessOnly","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\ReadWriteRequired","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SendToVerb","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SeparatorAfter","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SeparatorBefore","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\StaticVerbOnly","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SubCommands","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SuppressionPolicy","NAME NOT FOUND","Length: 16","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SuppressionPolicyEx","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\SuppressionPolicyEx","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\command\DelegateExecute","NAME NOT FOUND","Length: 12","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\command\DelegateExecute","NAME NOT FOUND","Length: 144","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\command\DelegateExecute","NAME NOT FOUND","Length: 90","Registry","Read"
"RegQueryValue","HKCR\Directory\background\shell\Powershell\command\command","NAME NOT FOUND","Length: 144","Registry","Read"
Temporary Workaround
Seeing that explorer.exe attempts to load C:\Windows\powershell.exe, creating a symlink under this path works as a temporary work around, i.e.:
mklink C:\Windows\powershell.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
makes the context-menu entry work again. I don't think the link is supposed to be there, though, so I'm still looking for a proper solution.
Source: Super User Archive (CC BY-SA 4.0)