Monday 7 January 2013

Execute Batch File in ASP.Net C#


Execute Batch File in ASP.Net C#


You can run Batch file (*.bat) in your ASP.Net Application.. Here is how we can achieve this:

Include the Namespace:

Using System.Diagnostics;

Then:

The path below indicate that batch file location is on root directory:


string str_Path = Server.MapPath(".") + "\\execute.bat";

Use the Code Snippet Below to achieve the goal:


        string str_Path = Server.MapPath(".") + "\\execute.bat";
        ProcessStartInfo processInfo = new ProcessStartInfo(str_Path);
        processInfo.UseShellExecute = false;
        Process batchProcess = new Process();
        batchProcess.StartInfo = processInfo;
        batchProcess.Start();

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top