我用VS自带的打包程序来制作,打包没有问题,只是想在安装后,让安装程序自动运行一个EXE文件,请教如何设置????

解决方案 »

  1.   

    可以做一个自定义安装类(从Installer类继承),添加安装项目的自定义操作,重写Installer的基类代码来运行你的Exe。
      

  2.   

    不知道你想安装啥文件要是NET FrameWork之类的话可以在安装项目里设置好系统必备,要是别的exe文件的话建议使用专用安装程序生成软件installshield 和Installer VISE之类的软件去做。希望对你有所帮助
      

  3.   

    能不能更详细点,我也从网上查阅,知道通过一楼的朋友的办法来解决,但是照着做了,却不成功,可能是重写Installer的基类不成功,进一步请教。
      

  4.   

    我做的继承类的代码是这样的,请指点
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Configuration.Install;
    using System.Diagnostics;
    using System.IO;
    namespace ClassLibrary1
    {
        [RunInstaller(true)]
        public partial class Installer1 : Installer
        {
            public Installer1()
            {
                InitializeComponent();
            }
            public override void Install(System.Collections.IDictionary stateSaver)
            {
                Process p = new Process();
                p.StartInfo.RedirectStandardOutput = false;
                p.StartInfo.FileName = @"mybat.exe";
                p.StartInfo.UseShellExecute = true;
                p.Start();
                p.WaitForExit();
                p.Dispose();            base.Install(stateSaver);        }    }
    }
      

  5.   

    我做的继承类的代码是这样的,请指点 
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Configuration.Install; 
    using System.Diagnostics; 
    using System.IO; 
    namespace ClassLibrary1 

        [RunInstaller(true)] 
        public partial class Installer1 : Installer 
        { 
            public Installer1() 
            { 
                InitializeComponent(); 
            } 
            public override void Install(System.Collections.IDictionary stateSaver) 
            {             base.Install(stateSaver);   //调整后,这句放在了上面            Process p = new Process(); 
                p.StartInfo.RedirectStandardOutput = false; 
            //    p.StartInfo.FileName = @"mybat.exe"; 
                p.StartInfo.FileName = @"C:\Program Files\营收系统\update.bat";   //这样只后到是能找到批处理文件了
                p.StartInfo.UseShellExecute = true; 
                p.Start(); 
                p.WaitForExit(); 
                p.Dispose(); 
            } 
        } 
    }
             //这就是想实现运行这个批处理文件,现在使用绝对路径,能找到这个批处理文件,我想请教,如何直接定位于当前系统安装的路径,这个批处理就在项目所在的目录中。还有一点,虽然找到了这个批处理文件,也运行了,但是批处理中要执行的两个命令文件却找不到。如果直接手动运行这个批处理是没有问题的,下面是批处理的内容:
    @ECHO OFFsn -Vr DevExpress.Data.v7.2.dll
    gacutil /i DevExpress.Data.v7.2.dll
    sn -Vr DevExpress.Utils.v7.2.dll
    gacutil /i DevExpress.Utils.v7.2.dllpause 
    提示sn gacutil不是可用的内部命令,好像还是路径问题
      

  6.   

    http://blog.csdn.net/lanwilliam/archive/2008/03/07/2156925.aspx
    给你个示例程序
      

  7.   

    调用已经没有问题了,只是遇到一个批处理的小问题,当单独执行这个批处理时没有问题,当用安装程序来执行时,出现如下提示
    提示'sn'不是内部或外部命令,也不是可运行的程序或批处理文件
    'gacutil'不是内部或外部命令,也不是可运行的程序或批处理文件
    以下是批处理的内容:@ECHO OFF sn -Vr DevExpress.Data.v7.2.dll 
    gacutil /i DevExpress.Data.v7.2.dll 
    sn -Vr DevExpress.Utils.v7.2.dll 
    gacutil /i DevExpress.Utils.v7.2.dll pause 请教如何处理
      

  8.   

     在安装类的提交事件里执行~~~~    
        /// <summary>
            /// 安装提交
            /// </summary>
            /// <param name="savedState"></param>
            public override void Commit(System.Collections.IDictionary savedState)
            {
                try
                {
                    base.Commit(savedState);                Process pro = new Process();
                    pro.StartInfo.UseShellExecute = true;
                    pro.StartInfo.FileName = this.Context.Parameters["targetdir"].ToString() + "SetUp.exe";//要执行的文件路径
                    pro.StartInfo.CreateNoWindow = false;
                    pro.Start();                Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }