-
Notifications
You must be signed in to change notification settings - Fork 8.2k
The path in the environment variable %Path% with double quotes is not recognized. (PowerShell 7.4.3) #24002
Copy link
Copy link
Open
Labels
Needs-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
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
- Set Environment Variables
PATH=C:\Users\WDAGUtilityAccount\Desktop\New folder
The folder contains a program named "ConsoleApplication1.exe",
when you run it, the output is "Program is run". - Open powershell
- Type in ConsoleApplication1 and enter
- "Program is run"
- Close powershell
- Set Environment Variables
PATH=C:\Users\WDAGUtilityAccount\Desktop\New;folder
Change the folder name to New;folder - Open powershell
- Type in ConsoleApplication1 and enter
- Error
- Open CMD
- Type in ConsoleApplication1 and enter
- "Program is run"
CMD can do it.
I found that powershell does not recognize paths in %Path% that are wrapped in double quotes. (Paths are wrapped in double quotes when they contain ";").
I'm sure powershell isn't set up that way on purpose?
Expected behavior
PowerShell 7.4.3
PS C:\Users\WDAGUtilityAccount> ConsoleApplication1
Program is runActual behavior
PowerShell 7.4.3
PS C:\Users\WDAGUtilityAccount> ConsoleApplication1
ConsoleApplication1: The term 'ConsoleApplication1' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Error details
PS C:\Users\WDAGUtilityAccount> Get-Error
Exception :
Type : System.Management.Automation.CommandNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The term 'ConsoleApplication1' is not recognized as a name of a cmdlet, function, script file,
or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
HResult : -2146233087
TargetObject : ConsoleApplication1
CategoryInfo : ObjectNotFound: (ConsoleApplication1:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : ConsoleApplication1
Statement : ConsoleApplication1
PositionMessage : At line:1 char:1
+ ConsoleApplication1
+ ~~~~~~~~~~~~~~~~~~~
InvocationName : ConsoleApplication1
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
CommandName : ConsoleApplication1
TargetSite :
Name : LookupCommandInfo
DeclaringType : [System.Management.Automation.CommandDiscovery]
MemberType : Method
Module : System.Management.Automation.dll
Message : The term 'ConsoleApplication1' is not recognized as a name of a cmdlet, function, script file, or
executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes,
SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin
commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[]
commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : ConsoleApplication1
CategoryInfo : ObjectNotFound: (ConsoleApplication1:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : ConsoleApplication1
Statement : ConsoleApplication1
PositionMessage : At line:1 char:1
+ ConsoleApplication1
+ ~~~~~~~~~~~~~~~~~~~
InvocationName : ConsoleApplication1
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1Environment data
PS C:\Users\WDAGUtilityAccount> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group