从C#中运行安装程序 [英] Running an installer from within C#

查看:473
本文介绍了从C#中运行安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写代码以下载和运行程序,例如notepad ++(npp.5.9.3.Installer.exe)可以在网上找到. 我使用ProcessStartInfo类运行它.但是,当我正常执行notepad ++安装程序时,它将在实际安装前向我显示一些步骤,例如选择语言,路径等.

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.

此致

推荐答案

有些安装程序支持-s或-silent开关,这意味着当您通过将-s switch传递给安装程序来安装软件时,它将以静默方式安装默认选项.尝试找出您的安装程序是否支持

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

这篇关于从C#中运行安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆