作者james999 (無傷大雅)
看板C_Sharp
標題[問題] Setup Project Silent啟動另一安裝包問題
時間Mon Sep 3 13:54:39 2018
各位大神們好,
小弟最近在用Setup Project打包程式,稱呼為A。
其中因為專案需求,我必須在A的安裝過程中安裝一個InstallShield打包的安裝包B,
在this.AfterInstall及this.BeforeUninstall的部份分別加入了「安裝」及「反安裝」B
的代碼,
不過卻無法順利執行,B產生的setup.log得到的ResultCode=-3,但原因不明…
懇請板上大神協助,這個問題困擾小弟好久,一直無法解決阿…謝謝!!
下述代碼中,InstallerHelper_AfterInstall及 InstallerHelper_BeforeUninstall內的
代碼,分別放在新建立的C# console程式中,卻能正常運行,
且WaitforExit()也能順利卡住,而B安裝包也能順利執行,ResultCode=0。
代碼如下:
--
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
using System.Configuration;
using System.Windows;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace FRWebService
{
[RunInstaller(true)]
public partial class InstallerHelper : Installer
{
public InstallerHelper()
{
InitializeComponent();
this.BeforeInstall += new
InstallEventHandler(InstallerHelper_BeforeInstall);
this.AfterInstall += new
InstallEventHandler(InstallerHelper_AfterInstall);
this.BeforeUninstall += new
InstallEventHandler(InstallerHelper_BeforeUninstall);
this.AfterUninstall += new
InstallEventHandler(InstallerHelper_AfterUninstall);
}
private void InstallerHelper_BeforeUninstall(object sender,
InstallEventArgs e)
{
try
{
String arg = "/s /uninst";
Process p = Process.Start("C:\\Program
Files\\Test\\setup_io.exe", arg);
p.WaitForInputIdle();
p.WaitForExit();
}
catch (Exception ex)
{
}
}
private void InstallerHelper_BeforeInstall(object sender,
InstallEventArgs e)
{
}
private void InstallerHelper_Committing(object sender,
InstallEventArgs e)
{
}
private void InstallerHelper_Committed(object sender,
InstallEventArgs e)
{
}
private void InstallerHelper_AfterInstall(object sender,
InstallEventArgs e)
{
try
{
String arg = "/s";
Process p = Process.Start("C:\\Program
Files\\Test\\setup_io.exe", arg);
p.WaitForInputIdle();
p.WaitForExit();
}
catch (Exception ex)
{
}
}
private void InstallerHelper_AfterUninstall(object sender,
InstallEventArgs e)
{
}
//Code to perform at the time of installing application
public override void Install(System.Collections.IDictionary
stateSaver)
{
System.Diagnostics.Debugger.Launch();
base.Install(stateSaver);
System.Windows.Forms.MessageBox.Show("Installing Application...");
}
public override void Uninstall(System.Collections.IDictionary
stateSaver)
{
System.Diagnostics.Debugger.Launch();
base.Uninstall(stateSaver);
System.Windows.Forms.MessageBox.Show("Uninstalling
Application...");
}
}
}
--
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.128.217
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1535954082.A.450.html
以下更新一下進度… 請大神幫幫忙呀
1.
setup.log的內容只有這樣
--
[ResponseResult]
ResultCode=-3
--
2.
Setup Project會產生兩個檔案,一個是msi,一個是exe,我嘗試用管理員身份運行該exe
,但也是無法…
P.S. 目前試過能成功的部份是…AfterInstall時運行B安裝包,但是不要用WaitForExit
的話,就能順利Silent安裝… 不過因為B安裝包裝完我還要做一些操作...這樣不行!
※ 編輯: james999 (220.132.128.217), 09/03/2018 13:56:24