private bool StartCommand(string commandtext, string key = " ") { try { string command = String.Concat(key, " ", " ", commandtext); Console.WriteLine(command); ProcessConsole.CommandRun(command); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private void Btn_stop_Click(object sender, EventArgs e) { foreach (CommandCMD c in commlist) { switch (c.CommandName) { case "Stop Server": ProcessConsole.CommandRun(c.CommandText); break; case "Stop MySql": ProcessConsole.CommandRun(c.CommandText); break; } } }
public Form1() { this.Text = Settings.Default.ManagerName + " v." + Application.ProductVersion; InitializeComponent(); statusabel.Text = "Wait Command"; progressBar1.Maximum = 100; ProcessConsole pc = new ProcessConsole(); Thread t = new Thread(pc.Run); t.Start(); ProcessConsole.CommandComplete += CommandCompleted; ProcessConsole.ProgressValue += ProgressValueChange; ProcessConsole.OutputData += GetOutputData; commlist.Add(new CommandCMD() { CommandName = "Start Server", CommandText = @"c:\Server\bin\Apache24\bin\httpd.exe -k start" }); commlist.Add(new CommandCMD() { CommandName = "Start Localhost", CommandText = @"start http://localhost" }); commlist.Add(new CommandCMD() { CommandName = "Start MySql", CommandText = @"net start MySQL" }); commlist.Add(new CommandCMD() { CommandName = "Restart Server", CommandText = @"c:\Server\bin\Apache24\bin\httpd.exe -k restart" }); commlist.Add(new CommandCMD() { CommandName = "Restart MySql", CommandText = @"c:\Server\bin\mysql-5.7\bin\mysqld --restart" }); commlist.Add(new CommandCMD() { CommandName = "Stop Server", CommandText = @"c:\Server\bin\Apache24\bin\httpd.exe -k stop" }); commlist.Add(new CommandCMD() { CommandName = "Stop MySql", CommandText = @"net stop MySQL" }); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { ProcessConsole.Stop(); Application.Exit(); }