Home > Software design >  How to running batch that require updating path?
How to running batch that require updating path?

Time:12-23

I want to use C# to call a batch script to install and run programs. This requires me to use two instances, one for the installation and one for the actual run, so that the path is updated. Here is my try:

var proc = new Process();
proc.StartInfo.FileName = @"Resources\Install Git.bat";
proc.StartInfo.UseShellExecute = true;
proc.Start();
proc.WaitForExit();
proc.StartInfo.FileName = @"Resources\Clone repo.bat";
proc.Start();

However in the second instance (Clone repo.bat), the path is still not updated, so that it "is not recognized as an internal or external command, operable program or batch file". Why is it so?

CodePudding user response:

At the end of the day, I just set the path variable right in the script.

  • Related