1

In Powershell, is it possible to define a string as $mystring="param1 param2" then pass that string to a process call

& c:\usr\bin\myprocess.exe "$mystring"

and have it interpreted as myprocess.exe param1 param2? where param1 and param2 are separate arguments

3
  • 1
    I think that's going to depend on how myprocess.exe parses it's arguments. Commented Jul 3, 2014 at 1:56
  • You may want to check out edgylogic.com/blog/powershell-and-external-commands-done-right, but I would agree with @mjolinor that it will fundamentally depend on how myexternalprocess.exe. Any reason why you would not define your params as an array e.g. $mystring=@("param1","param2") then just use & c:\usr\bin\myprocess.exe $mystring Commented Jul 3, 2014 at 3:06
  • Interesting; I recently wrote something quite similar to that (including a companion executable to really see the arguments). Commented Jul 3, 2014 at 3:09

1 Answer 1

0

You can do it if you pass argument array to Start-Process with the -ArgumentList parameter; e.g.:

$argList = "param1","param2"
start-process myprocess.exe $argList
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.