Search code examples
powershellparameter-passingexternalexecutable

How do I pass a quoted string as an argument to an executable in powershell?


I can start my application like this:

electron ./app/main.prod.js --input `SVGSVG`

However, starting it like this:

electron ./app/main.prod.js --input '<SVG></SVG>'

causes an error: < was unexpected at this time.

This is surprising to me since I am passing the special characters as part of a string.

Why does this problem happen?


Solution

  • These quotes won't be there anymore when PS finally passes the arguments to the program. You might try this call:

    Start-Process electron -ArgumentList "./app/main.prod.js --input `"<SVG></SVG>`""
    

    Sticking to your direct invocation, this will work too:

    electron ./app/main.prod.js --input `"<SVG></SVG>`"