通过windows服务安装MSI

本文关键字:MSI 安装 服务 windows 通过 | 更新日期: 2023-09-27 18:24:15

我有一个奇怪的问题,

我有一个WPF application。我已经为此创建了一个windows installer,安装将在用户的开始菜单中创建应用程序快捷方式。我正在通过windows service安装此MSI。通过windows服务安装很好,但它不会在"开始"菜单中创建快捷方式,我在"程序和功能"下也看不到这个应用程序。但如果我手动安装,一切都很好。知道为什么会发生这种事吗?

执行MSI 的代码

 Process installProcess = new Process();
                //Assign required properties
                installProcess.StartInfo.FileName = MSIEXEC;
                installProcess.StartInfo.RedirectStandardError = true;
                installProcess.StartInfo.UseShellExecute = false;
                LogManager.Write("Process object is created");
                //Create new StringBuilder instance
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(SYMBOL_SLASH);
                stringBuilder.Append(SYMBOL_INSTALL);
                stringBuilder.Append(installerPath);
                stringBuilder.Append(SYMBOL_QN);
                LogManager.Write("StringBuilder is created: " + stringBuilder.ToString());
                installProcess.StartInfo.Arguments = stringBuilder.ToString();
                installProcess.Start();

通过windows服务安装MSI

MSI的中的InstallAllUsers属性设置为false。我的windows服务在Local System account下运行,我的机器在administrator account下使用windows authentication登录。因此,当安装发生时,假设MSI是由用户安装的,而不是通过windows身份验证登录到机器的用户,因此它不会显示在"开始"菜单和"程序和功能"下。

我没有必要让InstallAllUsers为false,所以我简单地将其设为true,这解决了我的问题。