Windows 10 22H2 19045.3086
使用 Shift + 右键单击,我在上下文菜单中获得了“在此处打开 PowerShell 窗口”条目。我想我没有手动添加此条目,它要么是通过某个复选框启用的,要么是默认随窗口提供的。
今天它停止工作了。当我点击它时,我收到此错误:
应用程序未找到
注册表项Computer\HKEY_CLASSES_ROOT\Directory\shell\Powershell\command
和Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command
不包含完整路径,它们都设置为
powershell.exe -noexit -command Set-Location -literalPath '%V'
我无法修改它们以包含完整路径, (以管理员身份运行)如果我尝试更改它们regedit
则会出现错误。Cannot edit : Error writing the value's new contents
从命令提示符,在任何文件夹中,我都可以启动它,powershell
并且它可以正常加载。echo %PATH%
还显示这C:\Windows\System32\WindowsPowerShell\v1.0\
是我的路径的一部分。使用 Process Explorer,我还可以看到它位于环境PATH
中的变量中explorer.exe
。
为什么会出现此错误?我该如何修复?
编辑:sfc /scannow
没有修复它,重新启动也没有修复它,Windows 更新是“最新的”。
编辑 2:我运行了进程监视器,同时单击了“在此处打开 PowerShell 窗口”,并过滤了未成功且包含“powershell”的事件。但我不知道其中哪些应该失败,哪些不应该失败。
"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"
临时解决方法
看到explorer.exe
尝试加载C:\Windows\powershell.exe
,在此路径下创建符号链接可以作为临时解决方法,即:
mklink C:\Windows\powershell.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
使上下文菜单项再次起作用。不过,我认为链接不应该在那里,所以我仍在寻找合适的解决方案。
答案1
我也有这个问题。Explorer 无法打开 powershell.exe,很可能在 C:\Windows 目录中搜索它。但我通过更改目录中的注册表参数值解决了错误:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell\command
。我将其更改为C:\Windows\System32\WindowsPowerShell\v1.0powershell.exe -noexit -command Set-Location -literalPath '%V'
,并且运行良好。
如果您无法更改注册表参数,则需要通过在上下文菜单中单击 Powershell 文件夹来打开其权限,然后单击“高级”按钮,并通过单击蓝色的“更改”按钮来更改所有者。之后,您需要在底部字段中输入您的用户名,然后单击“检查名称”按钮并按“确定”。此外,您需要选中“替换子容器和对象的所有者”和“用可继承权限替换所有子对象权限条目”复选框,然后按“确定”。在弹出窗口中,也按“确定”,在第一个权限窗口中,您需要选择管理员并授予他们完全控制权。您可以访问所有这些参数。如果您想改回所有者,您需要执行所有这些操作,但在所有者的底部字段中,您需要输入NT SERVICE\TrustedInstaller
您的用户名。您可以通过谷歌搜索观看带有图片的教程,或者观看这篇文章,例如:https://www.groovypost.com/howto/take-full-permissions-control-edit-protected-registry-keys/
答案2
我搜索并在下面列出了所有包含的注册表上下文菜单项@shell32.dll,-8508
,这是“在此处打开 PowerShell 窗口”的文本。
检查你的是否相同。您也可以将此文本保存在文件中.reg
,然后双击将其导入注册表。我建议在进行注册表更新之前采取预防措施,至少创建一个系统还原保存点,以便在紧急情况下能够回滚到当前状态。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
[HKEY_CLASSES_ROOT\Drive\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Drive\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
[HKEY_CLASSES_ROOT\Directory\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"