Reputation: 151
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
Reputation: 151
Looks like piping the parameter was the way to go: -PassThru | Wait-Process; this got us thru the issues. ... ty.
Upvotes: 0
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
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