PowerShell allows you to execute exe files in 2 different ways. The easy way and the proper way.
The Easy Way:
The easy way to execute an exe with arguments is to just use the & symbol before the commands.
& c:\proc\my.exe –i –j –k c:\userdata
The issue with this is it will fire up in a different window and you will have no control over it. Which is ok for somethings but not for many MANY others.
The Proper Way:
So the solution is to use start-process instead. Start process gives you lots of extra control over the working process. Things such as the output, input, error control, PID, Status, etc….
I often us this cmdlet with the following keys, –wait and –NoNewWindow. These 2 combined give me the ability to have my code wait till this process is complete before processing further.
$exe = “c:\proc\my.exe”
$args = “–i –j –k c:\userdata”
start-process –filepath $exe –Arguments $args –wait –NoNewWindow
You have to also give the cmdlet the file path to the executable file in a variable and then a separate variable with the arguments of the executable as strings.
Have a look at: http://ss64.com/ps/start-process.html for further details.