Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background processes in batch with redirected output

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
like image 869
darckeen Avatar asked Sep 15 '11 21:09

darckeen


1 Answers

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.

like image 181
dbenham Avatar answered Nov 15 '22 20:11

dbenham