标题:Setup Project專案內使用Silent Mode執行InstallShield安裝包會有問題
只看楼主
yishiang0217
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-8-27
 问题点数:0 回复次数:1 
Setup Project專案內使用Silent Mode執行InstallShield安裝包會有問題
各位大神們好,

小弟最近在用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
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
using System.Configuration;
using System.Windows;
using
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...");
        }

    }
}
--
搜索更多相关主题的帖子: using System void object sender 
2018-08-27 22:54
yishiang0217
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-8-27
得分:0 
以下更新一下進度… 請大神幫幫忙呀

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

P.S. 目前試過能成功的部份是…AfterInstall時運行B安裝包,但是不要用WaitForExit的話,就能順利靜默安裝… 不過因為B安裝包裝完我還要做一些操作...
2018-09-03 09:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-489463-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.128396 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved