Skip to content

[Bug] Windows 11 24H2 Shift+Right-click "Open PowerShell here" fails on drive root with Set-Location error #27260

@jsws9517

Description

@jsws9517

Bug Description

Windows 11 24H2 version: Shift+Right-click "Open PowerShell here" on disk drive root (e.g., D:) throws error:

Set-Location : 路径中具有非法字符。

Or for paths with spaces:

字符串缺少终止符: "

Root Cause

The registry command at HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command uses:

powershell.exe -noexit -command Set-Location -literalPath "%V"

When %V equals D: (drive root without backslash), PowerShell interprets D: as the current working directory on that drive (e.g., D:\claude\workspace), not the drive root D:\.

Steps to Reproduce

  1. Windows 11 24H2
  2. Navigate to any disk drive root (D:)
  3. Shift+Right-click → "Open PowerShell here"
  4. Error occurs

Expected Behavior

PowerShell should open at the drive root directory.

Proposed Fix

Change the registry command to use single quotes instead of double quotes:

powershell.exe -noexit -command Set-Location -literalPath '%V'

This works correctly for all cases:

  • Drive roots: D:D:\
  • Subdirectories: D:\testD:\test
  • Paths with spaces: D:\My DocumentsD:\My Documents

Additional Context

This is a known issue introduced in Windows 11 24H2. The workaround requires modifying HKLM or HKCU registry keys for:

  • Directory\shell\Powershell\command
  • Directory\Background\shell\Powershell\command
  • Drive\shell\Powershell\command

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions