Я пытаюсь выполнить несколько команд без создания нового процесса каждый раз. В принципе, я хочу запустить командную оболочку DOS, переключиться на командную оболочку MySQL и выполнить команду. Вот как я называю процедуру (также ниже). Кроме того, как мне обрабатывать "\" в команде?
ExecuteCommand("mysql --user=root --password=sa casemanager", 100, false);
ExecuteCommand(@"\. " + Environment.CurrentDirectory + @"\MySQL\CaseManager.sql", 100, true);
private void ExecuteCommand(string Command, int Timeout, Boolean closeProcess)
{
ProcessStartInfo ProcessInfo;
Process Process;
ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
ProcessInfo.CreateNoWindow = false;
ProcessInfo.UseShellExecute = false;
Process = Process.Start(ProcessInfo);
Process.WaitForExit(Timeout);
if (closeProcess == true) { Process.Close(); }
}