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
- Windows 11 24H2
- Navigate to any disk drive root (D:)
- Shift+Right-click → "Open PowerShell here"
- 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:\test → D:\test
- Paths with spaces:
D:\My Documents → D:\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
Bug Description
Windows 11 24H2 version: Shift+Right-click "Open PowerShell here" on disk drive root (e.g., D:) throws error:
Or for paths with spaces:
Root Cause
The registry command at
HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\commanduses:When
%VequalsD:(drive root without backslash), PowerShell interpretsD:as the current working directory on that drive (e.g.,D:\claude\workspace), not the drive rootD:\.Steps to Reproduce
Expected Behavior
PowerShell should open at the drive root directory.
Proposed Fix
Change the registry command to use single quotes instead of double quotes:
This works correctly for all cases:
D:→D:\D:\test→D:\testD:\My Documents→D:\My DocumentsAdditional Context
This is a known issue introduced in Windows 11 24H2. The workaround requires modifying HKLM or HKCU registry keys for:
Directory\shell\Powershell\commandDirectory\Background\shell\Powershell\commandDrive\shell\Powershell\command