title: Running bat file on IIS server
body: <p>I'm trying to run a .bat file on a windows server 2008 R2 64bit with IIS version 6.1 SP1.
  On my local machine everything goes well but on server nothing happens, except for a process that gets created (cms.exe *32).</p>
  <p>From my search the main problem is permissions. I read in several places that IIS for default blocks access to batch files for security reasons. I do understand the problem but in my case there would be no security issue so i would like to still run my file.</p>
  <hr />
  <p>The solutions i found passed by implementing impersonation which means:</p>
  <ol>
  <li><p>Change web.config
  -&gt; identity impersonate=&quot;true&quot;</p>
  </li>
  <li><p>Change IIS Site Authentication
  -&gt; ASP.NET Impersonation Enabled</p>
  </li>
  <li><p>Give permissions to the file and folders</p>
  </li>
  <li><p>Even tried a different version of step 1
  -&gt; identity impersonate=&quot;true&quot; userName=**********</p>
  </li>
  </ol>
  <hr />
  <p>Give permissions to the IIS User:</p>
  <ol>
  <li>set allow service to interact with desktop on the IIS Admin Service</li>
  </ol>
  <hr />
  <p>To call the batch i use the following code in C#:</p>
  <pre><code>private void StartPervasive(string npu) 
  {
     
      try 
      {
         
          ProcessStartInfo startInfo = new ProcessStartInfo(ConfigurationManager.AppSettings.Get(&quot;PervasivePath&quot;));
      
          //startInfo.UseShellExecute = true;
          //startInfo.WorkingDirectory = ConfigurationManager.AppSettings.Get(&quot;PervasiveWorkingPath&quot;);
          //startInfo.WindowStyle = ProcessWindowStyle.Normal;
          //startInfo.RedirectStandardInput = true;
          //startInfo.RedirectStandardError = true;
          //startInfo.RedirectStandardOutput = true;
      
          //startInfo.FileName = ConfigurationManager.AppSettings.Get(&quot;PervasivePath&quot;);
       
          startInfo.Arguments = npu;
          Process myProcess = Process.Start(startInfo);
       
          //StreamReader sr = File.OpenText(ConfigurationManager.AppSettings.Get(&quot;PervasivePath&quot;));
          //StreamWriter sw = myProcess.StandardInput;
      
          //while (sr.Peek() != -1)
          //{
          //    string readed = sr.ReadLine();
          //    readed = readed.Replace(&quot;%1&quot;, npu);
          //    sw.WriteLine(readed + Environment.NewLine);
          //}
  
          //myProcess.WaitForExit();
          //myProcess.Close();
      
     } 
     catch (Exception ex) 
     {
       throw ex;
     }
  }
  </code></pre>
  <p>It should also be of note that i tried to execute other files including .exe files but with no results.</p>
  <p>Would appreciate any advice, help and or corrections to the steps described.</p>