Fadi Alkadi
Fadi Alkadi

Reputation: 781

launch an external program C# button, and function in this program

Im trying to make aprogram that has a connection to databas om mysql. I want that when the user click on a button the server will run, and Apatche and Mysql will even run.

here my code to run Xamp, But how to run Apatche and Mysql in it ?

  private void button4_Click_1(object sender, EventArgs e)
    {
        Process c = new Process();
        c.StartInfo.FileName = @"C:\xampp\xampp-control.exe";
        c.Start();
        //Start apatchi

    }

here pic of the program and the functions i wanna run

enter image description here

Upvotes: 0

Views: 236

Answers (1)

Mario Stoilov
Mario Stoilov

Reputation: 3447

Since you are running xampp there is an easier solution. Xampp usually comes packaged with a few .bat file that when run do exactly what you want. For example mysql_start.bat when run will only start MySql server and nothing else, while mysql_stop.bat will stop it (and nothing else). There is also a apache_start.bat and a apache_stop.bat.

You can execute these scripts just as you would an exe:

Process c = new Process();
        c.StartInfo.FileName = @"C:\xampp\mysql_start.bat";
        c.Start();

Upvotes: 2

Related Questions