Problem passing arguments to exe file
I have a powershell script that is passed arguments that have spaces in. In its script version I can invoke it as eg script.ps1 "this is stuff" or script.ps1 'this is stuff' and in both cases it sees a single argument.
However when its packaged into an exe if I run script.exe "this is stuff" it just sees This as as the argument. It does work as 'this is stuff' but this script is plugged into a third party toll that always used double quotes so I need it to work either way like it does for the script before its packaged (and I can not use the ps1 file with the third party tool which is why its now an exe file)
I am using 4.9.0 of the tools in VS Code and 5.1.1768 of Powershell
Comments (4)
-
-
I am having the same issue and would beĀ great to have this corrected so the exe accepts parameter values with space and comply to same rules as parameters accepted by PowerShell
-
This has been resolved and will be released this week.
-
- changed status to resolved
- Log in to comment
I ran into this and did some additional testing. I made a script that accepts a [string[]] parameter and simply writes the value back to the console.
From a command prompt, if I run "Script.exe -Var 'Foo Bar'", "Script.exe -Var 'Foo', 'Bar'", or "Script.exe -Var "Foo", "Bar"", it returns "Foo Bar". However, running "Script.exe -Var "Foo Bar"", returns "Foo". From a PowerShell console, no matter which way the parameter is passed to the executable, it only returns "Foo".
This is with version 4.9.1 and PowerShell 5.1.17134.858.