Home > Articles > .Net Framework Articles > Executing Batch File in C#

Executing Batch File in C#

by John Prathip   on Nov 19, 2015   Category: .Net Framework  | Level: Intermediate  |  Views: 1356    |  Points: 100   
Like this article? Bookmark and Share:
Executing Batch File in C#



    <add key="BatchFileDirectory" value="D:\Wolfcreek\Mail"/>
    <add key="BatchFileName" value="Sample_command_SendMail.bat"/>


string BatchFileDirectory= System.Configuration.ConfigurationManager.AppSettings["BatchFileDirectory"];

string BatchFileName = System.Configuration.ConfigurationManager.AppSettings["BatchFileName"];              

Process p = new Process();



string targetDir;

targetDir = string.Format(MailDirectory1);                  

p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

p.StartInfo.UseShellExecute = true;

p.StartInfo.WorkingDirectory = targetDir;

p.StartInfo.FileName = BatchFileName;                   




catch (Exception exmail)



Like this article? Bookmark and Share:

Most viewed Articles

User Comments

No response found, be the first to review this article.

Submit feedback about this article

Please sign in to post feedback

Latest Posts