How to read output of a console application launched by a windows service

  • Thread starter Thread starter jkschan
  • Start date Start date
J

jkschan

Guest
I've create a windows service run in LocalSystem account. In the service, a console application is launched and I need to capture the console output of the console application inside my windows service.

In my windows service, the console application is launched using CreateProcessAsUser, using an environment created using a logged-on user's session id obtained using .


To read the console application output, a pipe is created for redirecting console window output, and the handle is passed to the STARTUPINFO for creating the console application process. After the console application is launched, the code wait for the finish of the console application and then read the console application output. The logic of reading child console application output is working if not running within windows service.

When running inside windows service, I can see that the console application is launched with text output in the console window. But after the console application finishes, no console output text is read by my windows service.

Is there anyone had successfully done before the reading child console application process output inside windows service, please kindly let me know how you did it?



Continue reading...
 
Back
Top