Executing batch file from C# Permission issue

asp.net, batch-file, c#, vbscript, windows-server-2008-r2

Solution

For this to work your app pool needs to be run as a user who has access to the batch file. Check how to change your app pool identity for IIS 7 or IIS 6.

Problem

I have a batch file to execute a VB script. While executing the batch file by double clicking will work, But when I have done the same with C# its working on my local environment but not in the staging server (windows server 2008r2), Is there any permission level i need to apply for this execution. From the staging server I can double click and execute the batch file... I have logged in to the server with Administrator account and browsed the application as localhost. Is there anything I'm missing on the execution of batch file from C#, I don't think there is any problem with my C# code as its working fine on my local environment, anyway following is my C# code, ``` if (File.Exists(FileName*)) { System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(FileName); System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = FileName; proc.StartInfo.RedirectStandardError = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.UseShellExecute = false; proc.Start(); proc.WaitForExit(); } else { lblMsg.Text = "Sorry unable to process you request"; } ``` *FileName is the path to batch file. Also I have set full permission to the folders that containg both batch file and vbs files.

Original source