Alex Rivera | Logout

Background processes in batch with redirected output

Asked 2011-09-15T21:30:19.993
9

I'm trying to run several background processes from a batch file and have the output directed to a file. Is it possible to do this in Windows? This is what I've tried but it end up directing the output of the start program rather then background process.

start myapp.exe > myapp.out 2>&1
Edit
Report

1 Answer

12

Actually it is quite easy without using a helper batch file. You just need to run the application via cmd.exe instead, and make sure to escape the special characters so they pass through to cmd.exe.

You probably don't want to see an extra console window, so use the START /B option.

start /b "" cmd /c myapp.exe ^>myapp.out 2^>^&1

Each STARTed process must have its output directed to a unique file. Multiple processes cannot share the same output file.

answered 2012-07-29T20:13:39.670

Your Answer