6

インストーラーのカスタム アクションとしてInstallerClassusingを作成しています。しかし、コマンド プロンプトを使用して、サイレント モードでこれを正常にインストールできます。C#InstallerClass/quietInstallerClass/quiet

これには何らかの理由がありますか、それとも C# を使用してサイレント モードでインストールする方法はありますか?

以下は、Commit メソッド内で使用するコードです (オーバーライド)。

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = pathExternalInstaller;
p.StartInfo.Arguments = "/quiet";
p.Start();
4

5 に答える 5

8

静かなインストールとアンインストールを行うために使用するものは次のとおりです。

    public static bool RunInstallMSI(string sMSIPath)
    {
        try
        {
            Console.WriteLine("Starting to install application");
            Process process = new Process();
            process.StartInfo.FileName = "msiexec.exe";
            process.StartInfo.Arguments = string.Format(" /qb /i \"{0}\" ALLUSERS=1", sMSIPath);      
            process.Start();
            process.WaitForExit();
            Console.WriteLine("Application installed successfully!");
            return true; //Return True if process ended successfully
        }
        catch
        {
            Console.WriteLine("There was a problem installing the application!");
            return false;  //Return False if process ended unsuccessfully
        }
    }

    public static bool RunUninstallMSI(string guid)
    {
        try
        {
            Console.WriteLine("Starting to uninstall application");
            ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", string.Format("/c start /MIN /wait msiexec.exe /x {0} /quiet", guid));
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Process process = Process.Start(startInfo);
            process.WaitForExit();
            Console.WriteLine("Application uninstalled successfully!");
            return true; //Return True if process ended successfully
        }
        catch
        {
            Console.WriteLine("There was a problem uninstalling the application!");
            return false; //Return False if process ended unsuccessfully
        }
    }
于 2011-08-26T11:24:27.950 に答える
1

これは私にとってはうまくいきます。

Process process = new Process();
process.StartInfo.FileName = @ "C:\PATH\Setup.exe";
process.StartInfo.Arguments = "/quiet";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
于 2015-09-17T05:06:15.853 に答える
0

/Qインストール・パラメーターにリストされているまたは/QBパラメーターを使用してみましたか? 次のようになります。

p.StartInfo.Arguments = "/Q";

私はこのドキュメントからそれを得ました: http://msdn.microsoft.com/en-us/library/ms144259(v=sql.100).aspx

于 2013-04-12T17:53:11.590 に答える