Thursday 18 December 2014

C# Install software (.MSI) silently (Hiddenly)

        
        private Process mv_prcInstaller = new Process();    
        
        private void installSoftware(object sender, EventArgs e)
        {
            if (txtPath.Text.Length < 1)
            {
                MessageBox.Show("Please select a .msi file");
            }

            //Sentence to install -> /i
            manipulateSoftware("/i");
        }

        private void uninstallSoftware(object sender, EventArgs e)
        {
            if (txtPath.Text.Length < 1)
            {
                MessageBox.Show("Please select a .msi file");
            }

            //Sentence to uninstall -> /x
            manipulateSoftware("/x");
        }

        private void manipulateSoftware(string p_strAccion)
        {
            //The Argument will be like this
            mv_prcInstaller.StartInfo.FileName = "msiexec.exe";
            mv_prcInstaller.StartInfo.Arguments = p_strAccion + "\"" + txtPath.Text + "\"" +"/qn";
            mv_prcInstaller.Start();
        }

No comments:

Post a Comment