2
votes
  1. I need to start an executable from a WCF service which should run under the same service account that the WCF service uses. The WCF service is hosted in IIS and configured to run under a specific service account.
  2. I also need to get a handle to that process and save it somewhere (in database for example) so that I can kill later if it runs for a long time unexpectedly.
  3. I should be able to start multiple instances of that process in parallel with different arguments.

Is this possible OR do I need to create a windows service (assuming it does the same thing what executable does) and configure it with an account and start it from WCF service? Please let me know what is the right solution for this. thanks.

2

2 Answers

2
votes

You should just be able to kick off a new process using System.Diagnostics.Process and use the Start method. It will run under the context it was started under.

0
votes

If you want to get the handle for the process later, save its PID into your DB or file. Afterwards use Process.GetProcessById to get that handle.