I am trying to run multiple commands in one process instance and what I have is working but it hangs and does nothing after the 7th or 8th command in the streamwriter.
Here is my code:
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.CreateNoWindow = true;
p.StartInfo = info;
p.Start();
using (StreamWriter sw = p.StandardInput)
{
sw.WriteLine("copy /b updates\\EDB-master\\tables\\a*.sql a_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\b*.sql b_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\c*.sql c_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\d*.sql d_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\e*.sql e_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\f*.sql f_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\g*.sql g_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\i*.sql i_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\l*.sql l_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\m*.sql m_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\n*.sql n_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\o*.sql o_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\p*.sql p_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\q*.sql q_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\r*.sql r_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\s*.sql s_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\t*.sql t_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\v*.sql v_updates.sql");
sw.WriteLine("copy /b updates\\EDB-master\\tables\\w*.sql w_updates.sql");
}
p.WaitForExit();
I know I can accomplish writing all the SQL files into only a single file, but the reason I'm just going by first letter is because it's too large of a packet size for default MySQL servers with one large sql import. (program is for a public release and would hate to make everyone edit their max_packet_size just to use the app)
So what I basically need help with is figuring out why it only executes part of the commands or if there is another way I can do this