0
private void button1_Click_1(object sender, EventArgs e)
        {

            lbl_startingTest.Text = "Flashing DUT..";
            lbl_Result.Text = "Flash";
            
            Process fls1 = new Process();
            fls1.StartInfo.UseShellExecute = false;
            fls1.StartInfo.FileName = "C:\\test\\test\\bin\\Debug\\flash.bat";
            fls1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            fls1.Start();
            fls1.WaitForExit();
        }

I tried to use fls1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; to see if it hides CMD window. But when I run the application software it pops up CMD window when I click button on application. How can I hide the CMD window and still run .bat file in background?

PB stack
  • 1
  • 1
  • Does this answer your question? [How to hide cmd window while running a batch file?](https://stackoverflow.com/questions/1096591/how-to-hide-cmd-window-while-running-a-batch-file) – Zakaria Najim Nov 21 '22 at 23:28

2 Answers2

0

Try it without UseShellExecute = false; maybe change it to UseShellExecute to true.

 private void button1_Click_1(object sender, EventArgs e)
    {

        lbl_startingTest.Text = "Flashing DUT..";
        lbl_Result.Text = "Flash";
        fls1.StartInfo.UseShellExecute = true;
        Process fls1 = new Process();
        fls1.StartInfo.FileName = "C:\\test\\test\\bin\\Debug\\flash.bat";
        fls1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        fls1.Start();
        fls1.WaitForExit();
    }
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69
-2

The CreateNoWindow property might be what you are looking for.

fls1.StartInfo.CreateNoWindow = true;

frankM_DN
  • 365
  • 7
  • Extremely brief answers like this are usually downvoted and often removed. Consider fleshing it out more with some context and reasoning behind your suggestion. – bubbleking Nov 21 '22 at 20:55