zoukankan      html  css  js  c++  java
  • InstallShield安装打包编译自动化(3) 更新Package GUID,Product GUID以及Upgrade GUID

    版权声明: 可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息。

    在自动化编译过程中,如何修改产品的GUID,Package的GUID以及升级的GUID,受网友fishout的启发,找到了一些相关方面的资料,特与大家分享。

    关于InstallShield内部用脚本实现GUID的生成,请大家关注fishout的Blog他应该会更新到自己的Blog中的。

    下面是Aaron McLean写的一段VBScript示例代码,引用请保留原作者信息。 

    另外注意ISWiAutomation版本的不同,之前曾向导大家介绍过。

    InstallShield 2009和2010的GUID生成实例: 

    'Welcome to GuidChange 2009 and 2010 . Written by Aaron McLean. Written July 2001, Published November 2002, edited 2009
    'After 7 years I was asked to update the code to support IS 2009 and 2010
    'Use GuidChange 2009 and 2010.vbs for Installshield 2009 and 2010. 
    'Use GuidChange.vbs for IPWI 2.03, Developer 7.x, 8.x - Admin Studio
    'This is freeware as long as you keep mention my name in your code
    '
    'You will need a few things installed on your computer to run this Visual Basic Script
    '-VB6 Runtime and Windows Scripting Host - www.microsoft.com/scripting. Install Microsoft 'Windows Script 5.6 Download'

    'Drop an *.ism on guid.vbs
    'Supports Multiple *.ism's
    'Delete the last line if you don't want the message box - >>> msgbox "I'm done"
    'Send questions to aaronmclean@sbcglobal.net


    '---- ACCESS A FEW OF COM OBJECTS
    set fs = CreateObject("Scripting.FileSystemObject")
    set wshshell = CreateObject("wscript.shell")
    Set installer = wscript.CreateObject("WindowsInstaller.Installer"
    set args = Wscript.Arguments

    'Changed 9/10/2009 to use Installshield 2009 and 2010 COM naming conventions
    'Set GUID = CreateObject("InstallShield.Guid")
    Set GUID = CreateObject("ISWizUtil.CGUID")

    '---- If I get double clicked then show message box and quit 
    Dim argCount:argCount = Wscript.Arguments.Count
    if argcount < 1 then 
       
    MsgBox "Drop an *.ism on me and I will change the Package GUID, Product GUID, Upgrade GUID" & vbcr & vbcr & "GuidChange 1.0 Written by Aaron McLean, July 2001, Published November 2002"
       Wscript.Quit 1
    end if

    '---- If I find a ? in the cmd line then show the help and quit 
    if argcount >= 1 then
       
       
    If InStr(Wscript.Arguments(0), "?"Then ' Manual Launch from a command line
           MsgBox "Drop an *.ism on me and I will change the Package GUID, Product GUID, Upgrade GUID" & vbcr & vbcr & "GuidChange 1.0 Written by Aaron McLean, July 2001, Published November 2002"
              Wscript.Quit 1
       
    end if

    '---- If I find an *.ism in the cmd line then change the upgrade, package, and product guids.
    '---- guid.vbs will change multiple *.ism's at one time
    '---- The For statement is used to loop through all of the *.ism's that are dropped on GuidChange

       
    For each argument in args ' :msgbox " Argument: " & argument
          
        
    Set fileStuff = fs.GetFile(argument)         
            
        
    if CBool(fs.GetFile(fileStuff).Attributes and 1= TRUE then ' Is the file read only?
            fileStuff.Attributes = fileStuff.Attributes and not 14000 and not 1 ' Then remove the read only Attrib
        end if
            
        
    if instr(fileStuff,".ism"then    'Is this an Installshield Project
                
            
    'Changed 9/10/2009 to use Installshield 2009 and 2010 COM naming conventions
            'Set pProject = CreateObject ("ISWiAutomation.ISWiProject")
            Set pProject = CreateObject ("ISWiAuto16.ISWiProject")
            pProject.OpenProject fileStuff, True        
             pProject.PackageCode = GUID.CreateGUID() 'Delete this entire line if you don't want the package guid changed
            pProject.ProductCode = GUID.CreateGUID() 'Delete this entire line if you don't want the product guid changed
            pProject.UpgradeCode = GUID.CreateGUID() 'Delete this entire line if you don't want the upgrade guid changed
            pProject.SaveProject 'Saving the *.ism before closing it
            pProject.CloseProject 'Closing the *.ism
           else
               
    MsgBox "Only Installshield files with the *.ism file extension can be changed. Good-Bye"
               Wscript.quit 1
           
    end if
           
        
    next    
        
    end if    
       
    msgbox "I'm done"
     
    'Credits:
    'Installshield created the GUID object

    下面是针对IPWI 2.03,InstallShield Developer 7.x,8.x以及AdminStudio的示例代码:

    'Use GuidChange 2009 and 2010.vbs for Installshield 2009 and 2010. 
    'Use GuidChange.vbs for IPWI 2.03, Developer 7.x, 8.x - Admin Studio
    'This is freeware as long as you keep mention my name in your code
    '
    'You will need a few things installed on your computer to run this Visual Basic Script
    '-VB6 Runtime and Windows Scripting Host - www.microsoft.com/scripting. Install Microsoft 'Windows Script 5.6 Download'

    'Drop an *.ism on guid.vbs
    'Supports Multiple *.ism's
    'Delete the last line if you don't want the message box - >>> msgbox "I'm done"
    'Send questions to aaronmclean@sbcglobal.net


    '---- ACCESS A FEW OF COM OBJECTS
    set fs = CreateObject("Scripting.FileSystemObject")
    set wshshell = CreateObject("wscript.shell")
    Set installer = wscript.CreateObject("WindowsInstaller.Installer"
    set args = Wscript.Arguments
    Set GUID = CreateObject("InstallShield.Guid")

    '---- If I get double clicked then show message box and quit 
    Dim argCount:argCount = Wscript.Arguments.Count
    if argcount < 1 then 
       
    MsgBox "Drop an *.ism on me and I will change the Package GUID, Product GUID, Upgrade GUID" & vbcr & vbcr & "GuidChange 1.0 Written by Aaron McLean, July 2001, Published November 2002"
       Wscript.Quit 1
    end if

    '---- If I find a ? in the cmd line then show the help and quit 
    if argcount >= 1 then
       
       
    If InStr(Wscript.Arguments(0), "?"Then ' Manual Launch from a command line
           MsgBox "Drop an *.ism on me and I will change the Package GUID, Product GUID, Upgrade GUID" & vbcr & vbcr & "GuidChange 1.0 Written by Aaron McLean, July 2001, Published November 2002"
              Wscript.Quit 1
       
    end if

    '---- If I find an *.ism in the cmd line then change the upgrade, package, and product guids.
    '---- guid.vbs will change multiple *.ism's at one time
    '---- The For statement is used to loop through all of the *.ism's that are dropped on GuidChange

       
    For each argument in args ' :msgbox " Argument: " & argument
          
        
    Set fileStuff = fs.GetFile(argument)         
            
        
    if CBool(fs.GetFile(fileStuff).Attributes and 1= TRUE then ' Is the file read only?
            fileStuff.Attributes = fileStuff.Attributes and not 14000 and not 1 ' Then remove the read only Attrib
        end if
            
        
    if instr(fileStuff,".ism"then    'Is this an Installshield Project
            Set pProject = CreateObject ("ISWiAutomation.ISWiProject")
            pProject.OpenProject fileStuff, True        
               pProject.PackageCode = GUID.CreateGUID() 'Delete this entire line if you don't want the package guid changed
               pProject.ProductCode = GUID.CreateGUID() 'Delete this entire line if you don't want the product guid changed
               pProject.UpgradeCode = GUID.CreateGUID() 'Delete this entire line if you don't want the upgrade guid changed
               pProject.SaveProject 'Saving the *.ism before closing it
            pProject.CloseProject 'Closing the *.ism
           else
               
    MsgBox "Only Installshield files with the *.ism file extension can be changed. Good-Bye"
               Wscript.quit 1
           
    end if
           
        
    next    
        
    end if    
       
    msgbox "I'm done"
     
    'Credits:
    'Installshield created the GUID object

    参考链接:

    http://community.flexerasoftware.com/showthread.php?t=189920

    http://community.flexerasoftware.com/showthread.php?t=171334

  • 相关阅读:
    Maven配置及本地仓库设置
    【转载】精神目标
    Maven构建项目后项目报Error错误Java compiler level does not match the version of the installed Java project fac
    MYSQL数据库无法使用IP地址访问的解决办法
    Unity3D基础--动态创建和设置游戏对象
    把解压缩版的tomcat6注册成服务并设置自启动
    ARToolKit for Unity环境搭建(初步搭建成功)
    问题
    关于SSH
    论文随笔
  • 原文地址:https://www.cnblogs.com/wanbinghong/p/1814800.html
Copyright © 2011-2022 走看看