title: System.Diagnostics.Process.Start() gives access denied when running from WCF service
body: <p>I have a WCF service that calls a class that uses Process.Start(startInfo) to execute SQLPackage.exe which is the SQL Server Data Tools DACPAC execution utility.  If I access this code via a WPF test harness running in the debugger, it works as designed.  However, once the WCF service is running in IIS the line of code that calls Process.Start(startInfo) fails with an "Access is denied" message.</p>
  
  <p>I have made several attempts to resolve this; I added impersonation, I added the "runas" verb to the startInfo, I have changed both the app pool and the application hosting the service use a domain account with administrator privileges, I have verified that the SQLPackage.exe is permitted for that domain account in question, I have messed with the User Account Control settings -- nothing has worked, I get the same exact error every time.</p>
  
  <p>Unless there is some inherent restriction against a WCF service calling an executable via Process.Start(), it seems to me this has to be some kind of configuration issue but I'm pretty stumped at this point.  My machine is running Windows 7, our server is W2K8, both are having the same behavior.  The client calling the service is ASP.NET MVC, though I'm not sure that would matter.</p>
  
  <p>Does anyone know what I need to do to get this to execute successfully as a WCF service running in IIS?  I've read a lot of threads on various sites on similar topics but they mostly pertained to windows services and older operating systems and I never got any of those suggestions to work.  Thanks in advance!  If you need more information please let me know.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>            ProcessStartInfo startInfo = new ProcessStartInfo();
              startInfo.FileName = DacPacExecutablePath;
              startInfo.Arguments = FormDacPacArgumentString(dbname, server);
              startInfo.WindowStyle = ProcessWindowStyle.Hidden;
              startInfo.UseShellExecute = false;
              startInfo.Verb = "runas";
              startInfo.CreateNoWindow = true;
              startInfo.RedirectStandardOutput = true;
              using (Process process = Process.Start(startInfo)) //error on this line I think.
              {
                using (StreamReader reader = process.StandardOutput)
                {
                  string result = reader.ReadToEnd();
                  //do stuff
                }
              }
  </code></pre>
  
  <p>Here is the error:</p>
  
  <blockquote>
    <p>Message : Access is denied<br>
    Source : System<br>
    Stacktrace :    at   System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
      at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)<br>
      at MatterDBGenerator.DoGenerateDB(string dbname, InstallationServer server)   in c:\projects\pathstuff\MatterDBGenerator.cs:line 107
      at MatterDBGenerator.GenerateMatterDatabase(String dbname, InstallationServer server) in c:\projects\pathstuff\MatterDBGenerator.cs:line 86<br>
    TargetSite : Boolean StartWithCreateProcess(System.Diagnostics.ProcessStartInfo)     </p>
  </blockquote>