RunProgram with spaces in a powershell commandI am getting an error loading a string that has spaces and I need to pass between double quotes.
Names Default to Here(1);
parameter_A = "this has spaces";
parameter_B = "specific.domain.com";
command = "program -Name \!"" || parameter_A ||"\!" -Path \!"" || parameter_B || "\!"";
write(command );
// outputs the expected:
// program -Name "this has spaces" -Path "specific.domain.com"<BR />
add_result = RunProgram(
Executable( "powershell.exe" ),
Options( {"/c", command } ),
ReadFunction( "text" ));The parameter_A breaks the execution as it thinks there are more arguments passed. Yet, the command works if I copy and paste the output of write in powershell.
What am I missing?
Advanced Statistical ModelingConsumer and Market ResearchData Blending and CleanupRe: RunProgram with spaces in a powershell commandhere points to a thorough explanation of why the windows command line is so hard to use. The quotation marks don't really do what we think they do.
I'd mix the apostrophes and quotation marks, as you've done, because it is easier to understand.
Re: RunProgram with spaces in a powershell commandThis has helped me earlier with similar case: Pass quote into Run Program application
escapedquote = "\!\\!"";
Re: RunProgram with spaces in a powershell commandNames Default to Here(1);
parameter_A = "this has spaces";
parameter_B = "specific.domain.com";
command = "powershell "\!"program -Name '" || parameter_A ||"' -Path '" || parameter_B || '"\!"";
write(command );
// outputs the expected:
// powershell "program -Name 'this has spaces' -Path 'specific.domain.com'"
add_result = RunProgram(
Executable( "cmd.exe" ),
Options( {"/C", command } ),
ReadFunction( "text" ));This worked for me, not sure if there is a better solution that doesn't use single quotes.