-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-AnsweredThe question is answered.The question is answered.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Simply start powershell with args -WorkingDirectory "C:\":
D:\> pwsh -noexit -WorkingDirectory "C:\"
PowerShell 7.5.4
Set-Location: Cannot find path 'C:"' because it does not exist.This error occurs when I tried to open powershell from explorer.exe's one driver's root path, with shift+rightclick on the root folder:
The context menu comes from the registry with command:
powershell.exe -noexit -WorkingDirectory "%V"Although the builtin powershell is 5.x, I can reproduce this issue in the latest 7.x pwsh.exe too.
The error seems because powershell is trying to parse a bash-like string, and the trailing \ makes it throws error. I can also reproduce that with arguments like "C:\Users\". However, on Windows, the %V variable only expand to either C:\ from the root path or C:\Users from other (without trailing \).
Expected behavior
Should start powershell and navigate to C:\ normally.Actual behavior
Throws error:
Set-Location: Cannot find path 'C:"' because it does not exist.Error details
Exception :
Type : System.Management.Automation.ItemNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot find path 'C:"' because it does not exist.
HResult : -2146233087
TargetObject : C:"
CategoryInfo : ObjectNotFound: (C:":String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : PathNotFound
ItemName : C:"
SessionStateCategory : Drive
TargetSite :
Name : ResolveDriveQualifiedPath
DeclaringType : [System.Management.Automation.LocationGlobber]
MemberType : Method
Module : System.Management.Automation.dll
Message : Cannot find path 'C:"' because it does not exist.
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context
, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexist
ingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
at System.Management.Automation.SessionStateInternal.SetLocation(String path, CmdletProviderContext context, Boolean
literalPath)
at Microsoft.PowerShell.Commands.SetLocationCommand.ProcessRecord()
TargetObject : C:"
CategoryInfo : ObjectNotFound: (C:":String) [Set-Location], ItemNotFoundException
FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
InvocationInfo :
MyCommand : Set-Location
HistoryId : 1
InvocationName : Set-Location
CommandOrigin : Internal
PipelineIterationInfo :
0
1
0Environment data
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Resolution-AnsweredThe question is answered.The question is answered.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime