Mike Gmez
Mike Gmez

Reputation: 151

How to mix parameter strings in powershell

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

Upvotes: 0

Views: 200

Answers (3)

Mike Gmez
Mike Gmez

Reputation: 151

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

Upvotes: 0

xio
xio

Reputation: 640

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

Upvotes: 3

Venkataraman R
Venkataraman R

Reputation: 13009

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

Upvotes: 1

Related Questions