Powershell: The directory `PowerShell` in `My Documents` breaks existing PowerShell 1 launch functionality

Created on 24 Jun 2019  路  9Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

  • Open Windows Explorer and navigate to C:\.
  • Hit F4, [ALT] + [D], or click in the address bar.
  • Type PowerShell into the address bar.
  • Hit [ENTER]

Expected behavior

A Powershell Window opens with the current directory C:\

Actual behavior

Windows Explorer navigates to [IO.Path]::GetDirectoryName($profile).

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.1
PSEdition                      Core
GitCommitId                    6.2.1
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-Answered

Most helpful comment

Nice sleuthing, @vexx32.

File Explorer gives precedence to folders located directly in $HOME/Documents if you submit a mere _name_ rather than a path in the address bar - _unless_ you use the executable's filename extension explicitly (assuming you have no folders named *.exe).

Therefore, the - somewhat cumbersome - workaround is to _include the filename extension_; that is, submit powershell.exe instead of just powershell.

As an aside; anything that is neither recognized as a folder in $HOME/Documents nor as an executable in $env:PATH is apparently interpreted as a _URL_ and opens in the default browser.

All 9 comments

Hi @lennybacon The binary name for PowerShell 6 is actually "pwsh" not "powershell". Try typing that into explorer and see if it works. Thanks.

@bpayette Thank you for the hint. I edited the title to be more clear about where I see the issue.

Is the issue about Windows PowerShell or PowerShell Core? I see 6.2.1 in Environment data section.

@iSazonov this changes existing functionality indirectly by installing PowerShell Core.

Basically, if you _don't_ have PS Core installed, entering powershell in the address bar in File Explorer actually invokes powershell.exe as it's on %PATH%.

However, once you install PS Core, it creates the %HOME%\Documents\PowerShell folder. Attempting to invoke Windows PowerShell in the same way as before now defaults to opening this folder instead of invoking powershell.exe.

I don't think there's anything we can really do to fix this, though. Literally any creation of a similarly-named folder in a similar location will similarly break most things that could potentially be invoked this way.

If anything, this should be raised via Windows channels to see if there's anything that can / should be done on that end.

I can not repo.

Nice sleuthing, @vexx32.

File Explorer gives precedence to folders located directly in $HOME/Documents if you submit a mere _name_ rather than a path in the address bar - _unless_ you use the executable's filename extension explicitly (assuming you have no folders named *.exe).

Therefore, the - somewhat cumbersome - workaround is to _include the filename extension_; that is, submit powershell.exe instead of just powershell.

As an aside; anything that is neither recognized as a folder in $HOME/Documents nor as an executable in $env:PATH is apparently interpreted as a _URL_ and opens in the default browser.

I'm fine with the workaround entering ...exe!

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

Was this page helpful?
0 / 5 - 0 ratings