1)ISCmdBld.exe的问题:
目前用的是从翠竹心情(http://samblg.spaces.live.com/)处下载的InstallShield2009 Premier SP1版本,但是该版本存在无法使用ISCmdBld.exe从命令行生成安装包的问题。上网搜索,发现此处有一个解决办法:

http://blog.csdn.net/cnStreamlet/archive/2009/04/26/4125834.aspx

即将ISWIBuild.dll文件偏移 0x0002d391处的 75 修改为 EB

2)通过自动化接口调用InstallShield 报错:

通过步骤1后ISCmdBld.exe可以正常使用了,但新的问题又出现了:

我使用vbscript通过自动化接口来完成BuildNumber的自增功能,vbs源码如下

----------------------------------------

  Dim strVersion
  Dim arVersion

  Set m_ISWiProject = CreateObject("ISWiAuto15.ISWiProject")

  strFile = "e:\src\XMIIDP\IS2008\XMIIDP.ism" 
  m_ISWiProject.OpenProject strFile

  ' Get the current version
  strVersion = m_ISWiProject.ProductVersion

  ' Split the version into major.minor.build and increment the build number
  arVersion = Split(strVersion, ".")
  nNewBuild = arVersion(2) + 1
  ' Create the new version string and write to project
  strNewVersion = arVersion(0) & "." & arVersion(1) & "." & nNewBuild
'msgbox "a1" 
  m_ISWiProject.ProductVersion = strNewVersion
'msgbox "a2" 
  m_ISWIProject.SaveProject
'  msgbox "a3" 
  m_ISWIProject.CloseProject
msgbox "a4" 

-----------------------------------------

在msgbox “a4”之后Installshield出错

image

wscript.exe和cscript.exe均出现同样的情况。

3)利用AuotoIt的WORKAROUND:
因为我是在一个批处理程序中依次来执行包括vbs在内的一些命令的,不点击这个上图的那个确定就没法往下继续进行,实在是令人讨厌。一开始我采用AutoIt做了个模拟鼠标点击确定按钮的简单脚本,虽然方法丑陋但是确实暂时绕过了这个问题。脚本如下

-----------------------------------------

Dim $errcode
$errcode = 0

While $errcode <> 1
$errcode = WinActivate("WScript.exe - 应用程序错误")
WEnd

Send("{ENTER}")

-----------------------------------------

4)利用AuotoIt的WORKAROUND在WINDOWS 7上失效了:

就这样凑合着过了段时间,最近又需要在家里WIN7系统上执行同样的批处理,结果又发现了新的问题。WIN7系统提示的错误信息不同!实在是不想3)中丑陋的方法了,因此开始研究在自己的程序中调用vbs脚本看能否解决问题。

我的目的很简单:在自己的应用程序中捕获异常,只要不弹出错误提示就行了:)

5)在VC中调用vbs脚本:

我记得在CodeProject上看到过在VC中调用vbs脚本的方法,但是不记得了。只好再次上网搜索,最后采用的是

http://www.codeguru.com/Cpp/misc/misc/article.php/c3907/

上的方案,另外这篇文章也不错以后有机会再尝试

http://www.codeproject.com/KB/COM/scripter.aspx?msg=556234

把codeguru上那篇文章附带的源码修改了修改,开始在VC6中IDE追踪异常的发生位置。按下F5,根据IDE信息判断异常是退出程序时发生在ISUIServices_libFNP.dll模块中的,上网一搜该模块是属于Flexnet组件的,似乎目前还没有比较好的解决办法。因为我只要不弹出错误提示就可以了,因此尝试采用在try…catch(…)结构中手动卸载该DLL。

采用以下修改自MSDN实例程序的FindDllByName可以得到该DLL的句柄,传给FreeLibrary即可实现手动卸载该DLL

-----------------------------------------

#include <tlhelp32.h>

static BOOL FindDllByName (DWORD dwPID, LPCTSTR pszDllName, HMODULE& hm)
{
    BOOL          bRet        = FALSE;
    BOOL          bFound      = FALSE;
    HANDLE        hModuleSnap = NULL;
    MODULEENTRY32 me32        = {0};
    // Take a snapshot of all modules in the specified process.
    hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
    if (hModuleSnap == INVALID_HANDLE_VALUE)
        return (FALSE);
    // Fill the size of the structure before using it.
    me32.dwSize = sizeof(MODULEENTRY32);
    // Walk the module list of the process, and find the module of
    // interest. Then copy the information to the buffer pointed
    // to by lpMe32 so that it can be returned to the caller.
    if (Module32First(hModuleSnap, &me32))
    {
        do
        {
            if (stricmp(me32.szModule,pszDllName)==0)
            {
                hm = me32.hModule;
                bFound = TRUE;
            }
        }
        while (!bFound && Module32Next(hModuleSnap, &me32));
        bRet = bFound;   // if this sets bRet to FALSE, dwModuleID
        // no longer exists in specified process
    }
    else
        bRet = FALSE;           // could not walk module list
    // Do not forget to clean up the snapshot object.
    CloseHandle (hModuleSnap);
    return (bRet);
}

-----------------------------------------

6)结果:

呵呵,编程卸载DLL后XP系统上果然不弹出出错提示了:)

我把codeguru上文章中程序修改后命名为ISAutomationRunner.exe,再调用vbs时只要输入

ISAutomationRunner.exe XXX.vbs即可

点击下载ISAutomationRunner.exe

点击下载ISAutomationRunner源码

 

7)2010-04-23 更新:
ISAutomationRunner.exe中所采用的方法在win7平台下没有效果。解决方法有待寻找。

posted on 2010-04-21 19:26  silentmj  阅读(1534)  评论(0编辑  收藏  举报