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

how can i run a bat file from windows server in c#.net

Thanks
Sudheer.N
Posted
Updated 16-Jul-12 2:26am
v2
Comments
[no name] 16-Jul-12 8:25am    
System.Diagnostics.Process.Start.

If I understand your question correctly you can use
C#
Process.Start(pathToYourBatFile);
 
Share this answer
 
You can read a codeproject article about it here : Run Interactive Command Shell or Batch Files From ASP.NET[^]
 
Share this answer
 
You can use the below code
String BatchFilePath = "D:\\scripts\\batchfile1.bat";
if (File.Exists(BatchFilePath))
{

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = BatchFilePath;
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
}

:)
 
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