문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top