Amc_rtty
Amc_rtty

Reputation: 3813

Running an installer from within C#

I need to write code to download and run a program, e.g. notepad++ (npp.5.9.3.Installer.exe) this can be found on the web. I run it with the ProcessStartInfo class. However when I normally execute the notepad++ installer, it will show me a few steps before actually installing, like choose language, path etc.

Is there any way to programatically skip these steps, and install the software? I hope my question is clear. If it helps, I also attach the method that so far only starts the installer

        private int RunFile()
        {
            ProcessStartInfo psi = new ProcessStartInfo(GetFileFullPath());
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.CreateNoWindow = true;

            using (Process process = Process.Start(psi))
            {
                process.WaitForExit();
                if (process.HasExited)
                    return process.ExitCode;
            }
        }

Shall I pass some arguments for this to work? Thank you in advance.

Regards,

Upvotes: 1

Views: 3656

Answers (5)

Otiel
Otiel

Reputation: 18743

This will ONLY depend on the installer (npp.5.9.3.Installer.exe). You have to search if the installer provides options that can be used in command line, such as silentinstall.

EDIT: You can use the /S (capital S) option for Notepad++ to perform a silent install.

Upvotes: 1

CD..
CD..

Reputation: 74126

Use npp.5.9.3.Installer.exe /S for unattended installation of notepad++, and %ProgramFiles%\Notepad++\uninstall.exe /S for uninstall.

Upvotes: 4

Anders Abel
Anders Abel

Reputation: 69260

A wellwritten installer have options for silent installs with no user interface. If the installer is an .msi file there are options that can be passed to msiexec to make a silent install.

For other install systems there are sometimes options to. Automating installations without user involvement is a common task for system administrators, so if you have questions on a specific installation package I would suggerst asking at ServerFault or AppDeploy. Unfortunately there are many bad installation programs out there that doesn't support silent install.

Upvotes: 1

Massimiliano Peluso
Massimiliano Peluso

Reputation: 26737

you have to drive the installation emulating the user. It is possible send kind of command(message) to the other window from a C# application

have a look at the below

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/345d85e8-cc5f-4508-b3f2-74ee43521169/

Interact with other desktop-applications in windows using C# winforms

Upvotes: 1

Haris Hasan
Haris Hasan

Reputation: 30097

There are some installers which supports -s or -silent switches which means that when you install a software by passing -s switch to installer and it will silently install with default options. Try to find out whether your installer supports that or not

Upvotes: 2

Related Questions