Running a process in background?

Topics: User Forum
Mar 17, 2007 at 7:50 PM
I am not able to figure out how would I run the likes of Korn shell:

nmake >nmake.log 2>&1 &

In PowerShell I say:

start-process -noshell nmake.exe -arg ">nmake.log 2>&1" >$null

and I never succeed to redirect the nmake output to the log file. It always prints to screen. Does anybody knows how to do the above Korn shell command in PowerShell?
Mar 18, 2007 at 1:12 AM
start-process does not support redirection (and passing the argument cannot work, it's the caller who is responsible for doing the redirection. also, nmake, or any other executable, does not understand any of this syntax)

does "nmake > nmake.log" not work? you may also use the out-file command: "nmake | out-file nmake.log"
Mar 18, 2007 at 2:52 AM
Not sure what you mean by "nmake does not understand....". I did not say that it does understand the redirection. The shell understands but that is not what my question about. My question is about how I can do things that can easily be done in Korn shell or even with cmd.exe, such as for example in Korn shell:

while [ ... ]; do
nmake .... >nmake.log 2>&1 &


How can I do the above in PowerShell? How can I start a number of nmake background processes and then wait for them to finish? I could not figure that out so far with PowerShell. The above can easily be done even in cmd.exe, not speaking of the Korn shell or Bash, etc. Can you tell me if it is possible to do the same in PowerShell?
Mar 18, 2007 at 7:08 AM
PowerShell is very poor at doing job control and parallel processing, unfortunately.

However, you can do run multiple pipelines concurrently in different runspaces.

Take a look at It's not as elegant as Bourne shell & and wait, but should work ok.

Alternatively, you can install Cygwin :-)
Mar 18, 2007 at 12:07 PM
Thanks for the link. That is exactly what I mean. I will take a thorough look at it. At the first glance it looks complicated and unusual to me. Look at the above Korn shell code sample. See how elegenat, simple and nice it is.

This is all frustrating. I did not know that there is no simple and obvious way to run processes in the background. It is strange that such an important feature was left aside when PowerShell was developed. As to Cygwin, I use MKS Toolkit for many years. When I attemted to rewrite what I do with the MKS Toolkit Korn shell, I got a number of problems such as this one. Though PowerShell has undoubtly nice and useful features, it also lacks features that would allow people to easily switch to it.
Mar 18, 2007 at 1:18 PM
I still am thinking about start-process. This command seems to be doing the job:

start-process -noshell powershell.exe -arg "-command nmake.exe >nmake.log 2>&1" >$null

Can anybody tell if the above command can be used in place of the likes of Korn shell:

nmake >nmake.log 2>&1 &