简体   繁体   中英

How to run .Bat file in asp.net,IIS

How to start XXX.bat file in IIS? I want to run this file..while i am executing in my development PC its perfectly running. But While I deployed in IIS its working and not executing.bat file

So please guide me how to do...My Code as follows

\\

 string exefile = ConfigurationManager.AppSettings["exefile"]; //exefile="D:\\XX\\xxx.bat"
  System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(exefile);
        psi.UseShellExecute = false;
        psi.CreateNoWindow = true;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardInput = true;
        psi.RedirectStandardError = true;
  System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);
\\

I would check security.

The user that "hosts" the IIS proccess does likely not have the rights to run exeute files outside the IIS folder.

Also posting a actual error message would be helpfull. On a side note if its Exepction is of type UnauthorizedAccessException then its very likely what i describe above.

I had this problem and for me it was the location of the bat file. It had placed the bat file in it's own folder under the solution in Visual Studio but this meant IIS could not access it. When I moved the bat file to the wwwroot folder everything worked as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM