0

I need to pass some parameters to this start-process command in powershell. So far have been unable to make it work passing the parameters to the application. Seems like I cannot enclose in quotes my parameters to the application, without them, the command works fine.

Start-Process "c:\app\myApp.exe /S '/V /qn AllUsers=1 SN=123-456' " -NoNewWindow -Wait -PassThru

Is there any way to combine quotes inside quotes in powershell ? ... thanks

3 Answers 3

3

you can try this method

Start-Process -FilePath "c:\app\myApp.exe" -ArgumentList "/S","'/V /qn AllUsers=1 SN=123-456'" -NoNewWindow -Wait -PassThru

using -ArgumentList "arg1","arg2",...

for example:

Start-Process -FilePath "python" -ArgumentList "-c","print('hello')" -NoNewWindow -Wait -PassThru

Output:

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
     38       3      508       1476       0.02   4932   4 python

hello
Sign up to request clarification or add additional context in comments.

Comments

1

You can provide the whole parameter list as a single string:

Start-Process -FilePath "c:\app\myApp.exe  -ArgumentList "/S '/V /qn AllUsers=1 SN=123-456'" -NoNewWindow -Wait -PassThru

Or You can split them

Start-Process -FilePath "c:\app\myApp.exe  -ArgumentList "/S","'/V /qn AllUsers=1 SN=123-456'" -NoNewWindow -Wait -PassThru

More information on start-process

1 Comment

Thanks .... for some reason, this works: -ArgumentList "/S","'/V /qn'" but this does not: -ArgumentList "/S","'/V /qn","AllUsers=1" it just wont accept the last parameter "foo=123"
0

Looks like piping the parameter was the way to go: -PassThru | Wait-Process; this got us thru the issues. ... ty.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.