How do I create an installation menu with check box?

-3

I'm creating an installation menu with CheckBox , in this menu will have installation softwares in each CheckBox, after selecting the CheckBox, will have a button that will execute all the checkbox > selected. Each CheckBox will run a software installation, but all the selected ones run at once, how do I make it install at a time? My code:

if (CheckBox2.Checked)
    Process.Start(@"\Index\Menu de Instalacao\Softwares\Utilitarios\PROGRAMA1.EXE");

if (CheckBox3.Checked)
    Process.Start(@"\Index\Menu de Instalacao\Softwares\");
    
asked by anonymous 25.04.2018 / 23:09

1 answer

0

The following method takes the path of an executable, calls the executable, and waits until it exits.

public void AguardarAteEncerrar(string caminhoExecutavel)
{
    var processo = new Process
    {
        StartInfo = new ProcessStartInfo 
        {
            FileName = caminhoExecutavel
        }
    };

    processo.Start();
    processo.WaitForExit();
}

You would use this:

if (CheckBox2.Checked)
    AguardarAteEncerrar(@"\Index\Menu de Instalacao\Softwares\Utilitarios\PROGRAMA1.EXE");

Keep in mind that this will hold the thread, so avoid using it on the same thread in the GUI. I suggest you use a BackgroundWorker in this case.     

12.05.2018 / 20:30