title: ASP.Net run exe on server from an API call
body: <p>I have a WebAPI that works great but need to add the ability to call to an EXE on the server to run some tasks with Video, the server is our machine and running IIS to host the WebAPI.  </p>
  
  <p>I have tried it working with Process() and the calls make it to the cmd.exe file I have written but the issue is that the user is IUSER and this won't work as the Video processing needs to use system hardware so needs to be the current logged in Windows User.</p>
  
  <p>I don't want to give the IUSER this privilege for obvious security reasons so I am looking for another way to call and pass data to the an EXE or background task (Short running &lt;3seconds) and for that process to reply with the results.</p>
  
  <p>It's all on the server which we have full control over.</p>
  
  <p>Current Code:</p>
  
  <pre><code>string exeLoc = Environment.ExpandEnvironmentVariables(baseEXELocation);
  using var process = new Process();
  process.StartInfo.FileName = exeLoc; 
  process.StartInfo.Arguments = $"{command}";
  process.StartInfo.CreateNoWindow = true;
  process.StartInfo.UseShellExecute = false;
  process.StartInfo.RedirectStandardOutput = true;
  process.OutputDataReceived += (sender, data) =&gt;
  {
     if (!String.IsNullOrEmpty(data.Data))
     {
        Console.WriteLine(data.Data);
        consoleData += data.Data;
      }
  };
  process.Start();
  process.BeginOutputReadLine();
  var exited = process.WaitForExit(1000 * 10);     // (optional) wait up to 10 seconds
  </code></pre>
  
  <p>Thanks  </p>