现在的位置: 首页 > 综合 > 正文

vista 中的activex部署

2013年07月07日 ⁄ 综合 ⁄ 共 1800字 ⁄ 字号 评论关闭

晕,刚才费事写了半天的东东都丢了。 那就从简吧。

 

之前写的activex打的包中是这样写的:

[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
hook1=hook1

[hook1]
run=msiexec.exe /i "%EXTRACT_DIR%\MyActivexSetup.msi" /qn

 

而我们cab包中没有msiexec.exe这个程序,所以不行。

解决方法是自己创建一个工程,删掉除program.cs之外的文件,代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace WinInstaller
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                log("Incorrect argument.. ");
                return;
            }
            string file = args[0];

            log("The setup file path:" + file);

            if (!File.Exists(file))
            {
                log("Cann't found the specified setup file.");
                return;
            }

            try
            {
                log("Installing....");
                ProcessStartInfo info = new ProcessStartInfo();
                info.FileName = "msiexec.exe";
                info.Arguments = string.Format("/i {0} /qn", file);
                Process prc = Process.Start(info);

                if (prc.WaitForExit(6000))
                {
                    log("Install finished...");
                }
                else
                {
                    log("Time out.");
                    prc.Kill();
                }
            }
            catch (Exception ex)
            {
                log("Error happened..");
                log(ex.ToString());
            }
        }

        private static void log(string message)
        {
            Trace.WriteLine(message);
        }
    }
}

然后将inf修改为

[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
hook1=hook1

[hook1]
run="""%EXTRACT_DIR%\WinInstaller.exe""" %EXTRACT_DIR%\MyActivexSetup.msi

抱歉!评论已关闭.