GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable `Open Here` context menu on Windows to work with root of a drive by SteveL-MSFT · Pull Request #8287 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 16, 2018 •
edited by TravisEz13
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

The fundamental problem is that Microsoft cpp command line parsing rules indicate that a backslash followed by a quote is a quote, otherwise, it is literal. So this:

pwsh -noexit -workingdirectory "c:\"

Is received as c:" at argument parsing time. Of course, this is a bit more complicated as Open Here also uses -Command. So:

pwsh -noexit -workingdirectory "c:\" -command 1+1

Becomes c:" -command 1+1 as the argument value to -workingdirectory. And -command must be last in the command line.
Fix is to add a hidden switch for the purpose of the Open Here context menu called -RemoveWorkingDirectoryTrailingCharacter. This allows Open Here's command line to pad the path:

pwsh -noexit -removeworkingdirectorytrailingcharacter -workingdirectory "C:\!" -command 1+1

Now all the args can get parsed appropriately as the working directory path never ends with a trailing backslash.

Fix #8278

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vexx32 reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Travis Plunk (TravisEz13) Nov 16, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Travis Plunk (TravisEz13) and Andrew (anmenaga) November 16, 2018 02:26
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested a review from Dongbo Wang (daxian-dbw) as a code owner November 16, 2018 02:26
Steve Lee (POWERSHELL)
[package]
8abda7d
support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the trailing-quote branch from b26c80a to 8abda7d Compare November 16, 2018 02:35
@iSazonov Ilya (iSazonov) added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Nov 16, 2018
TravisEz13
Travis Plunk (TravisEz13) approved these changes Nov 16, 2018
View reviewed changes
bergmeister
Christoph Bergmeister (bergmeister) reviewed Nov 16, 2018
View reviewed changes

@bergmeister Christoph Bergmeister (bergmeister) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this problem is Windows specific wouldn't it make sense to expose -RemoveWorkingDirectoryTrailingCharacter only on Windows?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 17, 2018

Copy link
Copy Markdown
Member Author

Christoph Bergmeister (@bergmeister) good point, I'll update

TravisEz13 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Steve Lee (POWERSHELL)
[package]
ca182e9
address Chris' comment
@TravisEz13
Travis Plunk (TravisEz13) merged commit b7daa79 into PowerShell:master Nov 19, 2018
Ilya (iSazonov) pushed a commit to iSazonov/PowerShell that referenced this pull request Nov 29, 2018
@SteveL-MSFT @iSazonov
Enable Open Here context menu on Windows to work with root of a dri…
a413040
…ve (PowerShell#8287)

support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
@mklement0 Michael Klement (mklement0) mentioned this pull request Nov 12, 2019
Fix Start-Job working directory path with trailing back slash #11041
Merged
8 of 14 tasks
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the trailing-quote branch June 6, 2020 02:28
@daxian-dbw Dongbo Wang (daxian-dbw) mentioned this pull request Dec 2, 2025
Start program with -WorkingDirectory "C:\" raises Set-Location: Cannot find path 'C:"' because it does not exist. #26541
Closed
5 tasks done
@yotsuda Yoshifumi (yotsuda) mentioned this pull request Feb 7, 2026
Fix: Use %1 instead of %V! for folder context menu paths #26718
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @TravisEz13
Enable Open Here context menu on Windows to work with root of a dri…
6fa8e01
…ve (PowerShell#8287)

support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 approved these changes
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
+1 more reviewer
@bergmeister Christoph Bergmeister (bergmeister) bergmeister left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PowerShell 6.1.1 - Context Menu "Open Here" gives error when path is root of drive

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@SteveL-MSFT @bergmeister @TravisEz13 @iSazonov
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.