3
Answers

How to run a batch file from current directory?

shijin

shijin

8y
387
1
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)