Question

Like the title says, i'm trying to install an .exe silently (say, for example, inkscape) through my application written in WPF C#. The problem is, the install process i use always return an exception and fails.

Here is the code that i use :

    public static bool StartInstall(string pathtofile)
    {
        try
        {
            Process process = new Process();
            process.StartInfo.FileName = "Temp.exe";
            process.StartInfo.Arguments = string.Format(" /S", pathtofile);
            process.Start();
            process.WaitForExit();
            Console.WriteLine("Silent Install was successful.");
            return true;
        }
        catch
        {
            MessageBox.Show("Error!");
            return false;
        }
    }

According to this website, the switch for a silent install for NSIS packaged exes is /S. I'm not sure whether or not i'm doing something wrong in the syntax, though.

The code i'm using come from this stackoverflow post. It does work for a .msi package. Maybe it does not work for NSIS exes?

I'm relatively clueless as to why it does not work. The code above will crash at the "process.Start()" line, most probably because of a unknown command or something.

I'd be thankful if anybody could shred a bit of light as to how to launch that process for a NSIS installer.

Was it helpful?

Solution

I have solved the problem with the help of csharpfolk.

My problem was a combination of two different cause :

First, Admin privileges were indeed required to run the application.

Second, the line "process.StartInfo.Filename" requires the full path to the file. As soon as i changed it to "C:\Downloads\Temp.exe", it worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top