Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a batch file which I want to execute on the server from webapplication developer in asp.net

But when I use below code to run the batch file, I get access denied error.
C#
ProcessStartInfo psi = new ProcessStartInfo();
        psi.FileName = Server.MapPath(ConfigurationManager.AppSettings["Path"]) + "TestingApplication.bat";
       

        Process proc = new Process();
        proc.StartInfo = psi;
        proc.Start();

Batch file is placed in the bin folder of the application.

My web application is using forms authentication.
I need to know how to provide premissions for execution of this batch file.
Posted
Updated 4-Apr-15 2:03am
v3
Comments
CHill60 4-Apr-15 8:05am    
If you run the batch file manually do you get the same error?
rupali4 4-Apr-15 8:32am    
When I run the batch file manually it executes properly.
Even if I schedule this same batch file, it will execute.
ramyajaya 4-Apr-15 22:08pm    
Check this discussion http://stackoverflow.com/questions/5519328/executing-batch-file-in-c-sharp to track your issue

1 solution

Web app processes run at a lower security level than users so you must make sure your web process has access to the batch file and what it is doing within that file.

http://www.iis.net/learn/manage/configuring-security/application-pool-identities[^]

Guidelines for Resolving IIS Permissions Problems[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900