Can’t Access PowerShell from Right-Click Menu on Windows 11

0
9
Asked By CuriousGeorge42 On

I've been trying to open PowerShell directly from the context menu in Windows 11, but I'm running into an error. Whenever I select 'Open PowerShell window here' after shift-right-clicking, I get this error message: "Set-Location : A positional parameter cannot be found that accepts argument 'folder'." It specifies an issue with my command, particularly when trying to set the location to a folder on my desktop. I've already tweaked some registry keys located at HKEY_CLASSES_ROOTDirectoryshellPowershellcommand but it hasn't worked. Is there another registry key I may need to adjust? Interestingly, if I just right-click and choose 'Open in terminal', the PowerShell terminal opens up fine. I think the recent registry hack I performed to revert to the old right-click menu might be contributing to the problem.

3 Answers

Answered By CodeWizard99 On

I encountered a similar problem a while back and found a script that might help you fix this. Check out this tool: [Repair-PowershellContextMenu.ps1](https://github.com/krzydoug/Tools/blob/master/Repair-PowershellContextMenu.ps1). It worked for someone else on another forum, so it could do the trick for you too!

Answered By TechSavvy24 On

It seems like the issue might be related to how the path is quoted in your registry settings. Make sure you’re using the right syntax for paths that have spaces, which means it should look something like this: `powershell.exe -NoExit -Command "Set-Location -LiteralPath '%V'"`. Double-check that your quotes and arguments match exactly; that could be causing the error you’re seeing.

Answered By PowerShellNinja On

Instead of using `Set-Location`, consider using `pushd` to change directories. It's basically an alias for `Set-Location`, but it could behave differently in your case. Also, be sure to wrap your path in quotes: "C:pathtoNew Folder". The space in your path is likely the problem here.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.