shijin

shijin

  • NA
  • 3
  • 696

How to run a batch file from current directory?

Feb 1 2016 3:02 AM
I have written a code for adding a registry key on  a batch file and executed in my project as follows.But i want to run it from current directory.  Please help me to add current path and run the file from that.
 
System.Diagnostics.Process regadd = new System.Diagnostics.Process();
regadd.StartInfo.FileName = "C:\\Users\\win7\\Desktop\\Regkeyadd.bat";
regadd.StartInfo.RedirectStandardError = false;
regadd.StartInfo.RedirectStandardOutput = false;
regadd.StartInfo.UseShellExecute = true;
regadd.Start();
regadd.WaitForExit();

Answers (3)