Forum Discussion
Run Start-Process with -ArgumentList when an argument also contains a -a
Run powershell Start-Process -FilePath "$env:PROGRAMDATA\GrapeCity\gclm\gclm.exe" -ArgumentList @("product-id", '-a "License-Key"');
Start-Process : Cannot bind parameter because parameter 'ArgumentList' is specified more than once. To provide
multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter
value1,value2,value3".
At line:1 char:115
+ ... clm.exe -ArgumentList 742a5cf8-2204-4873-9dc9-ff56d67411bd -a "065042 ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : ParameterAlreadyBound,Microsoft.PowerShell.Commands.StartProcessCommand
Error: Process completed with exit code 1.
From looking at the error message, I tried this command (wrapping the -ArgumentList in quotes):
powershell Start-Process -FilePath "$env:PROGRAMDATA\GrapeCity\gclm\gclm.exe" "-ArgumentList 'product-id', '-a licensekey'";
And it works!
Thank you for your help!
- LainRobertsonOct 15, 2024Silver Contributor
Hi, Joe.
I'm glad it's working - that's all that matters, but there's some inconsistencies here.
From the second last post, the error's showing that there is no comma between the product key and the -a, which doesn't reflect the command you mentioned running:
Next, enclosing the entire ArgumentList component in double quotes causes everything - including the "-ArgumentList" to be treated as a single parameter to gclm.exe. This seems not to be an issue for gclm.exe, but it's important to understand what's going on as there will be other times this strategy won't work.
Here's an example, where I'm using the command prompt in lieu of gclm.exe.
Output
Here, you can see the whole string's been passed in as the parameter.
Cheers,
Lain