Monday, September 26, 2011

Executing .bat files on button click asp.net

 protected void btn_Click(object sender, EventArgs e) 
{
   ProcessStartInfo psi = new ProcessStartInfo(@"C:\bank.bat");
          psi.RedirectStandardOutput = true;
          psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
          psi.UseShellExecute = false;
          System.Diagnostics.Process listFiles;
          listFiles = System.Diagnostics.Process.Start(psi);
          System.IO.StreamReader myOutput = listFiles.StandardOutput;
          listFiles.WaitForExit(2000);
}




//bat file code

@echo off
cd\
c:


start iexplore.exe www.google.com

No comments:

Post a Comment