作者: yishiang0217
查看: 1510|回复: 1

[求助] Setup Project專案內使用Silent Mode執行InstallShield安裝包會有問題

[复制链接]
yishiang0217 发表于 2018-8-28 11:51:45 | 显示全部楼层 |阅读模式
查看: 1510|回复: 1
各位大神們好,

小弟最近在用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...");
        }

    }
}
--


回复 论坛版权

使用道具 举报

 楼主| yishiang0217 发表于 2018-9-3 09:49:49 | 显示全部楼层
以下更新一下進度… 請大神幫幫忙呀

1.
setup.log的內容只有這樣
--
[ResponseResult]
ResultCode=-3
--
2.
Setup Project會產生兩個檔案,一個是msi,一個是exe,我嘗試用管理員身份運行該exe,但也是無法…

P.S. 目前試過能成功的部份是…AfterInstall時運行B安裝包,但是不要用WaitForExit的話,就能順利靜默安裝… 不過因為B安裝包裝完我還要做一些操作...
您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-4-19 02:24, Processed in 0.542514 second(s), 29 queries , Gzip On.

快速回复 返回顶部 返回列表