Create C # Application that opens and install winrar.exe from my pendrive

0

I want to create a windows form type application in C # that opens an installation assistant .exe and automatically press the Next> buttons. Next > Finish (To give an example)

I already have the test button created and I have the code to open the .exe through:  System.Diagnostics.Process.Start (@ "E: \ ..... .exe);

also create a function for the application to go forward and I'm passing the "Enter" key several times to give the button "next" of the application but it does not work, if someone could help me I would appreciate it, aki I leave my cod until now.

// THIS IS THE BUTTON CODE

private void button1_Click(object sender, EventArgs e)
        {

            System.Diagnostics.Process.Start(@"E:\programas pcs\winrar-x64-411es.exe");
            Thread.Sleep(1000); 

            Funciones.ActivateApp("winrar-x64-411es.exe");

            Thread.Sleep(2000);          


            SendKeys.SendWait("{ENTER}");
            Thread.Sleep(2000);
            SendKeys.Send("{ENTER}");
            Thread.Sleep(2000);
        }

//FUNCION ACTIVATEAPP

public static void ActivateApp(string processName)
    {
        Process[] p = Process.GetProcessesByName(processName);       
        if (p.Count() > 0)
            SetForegroundWindow(p[0].MainWindowHandle);
    }
    
asked by HOLDTHEDOOR 01.06.2018 в 20:16
source

1 answer

1

try using these parameters and methods

 ProcessStartInfo psi = new ProcessStartInfo();
 psi.Arguments = "/s";
 psi.CreateNoWindow = true;
 psi.WindowStyle = ProcessWindowStyle.Hidden;
 psi.FileName = @"E:\programas pcs\winrar-x64-411es.exe";
 psi.UseShellExecute = false;
 Process.Start(psi);
    
answered by 01.06.2018 / 22:42
source