InstallShield安装打包编译自动化(3)- 更新Package GUID,Product GUID以及Upgrade GUID

本文提供了一段VBScript示例代码,用于自动化更改InstallShield项目的Package GUID、Product GUID及Upgrade GUID。适用于InstallShield 2009和2010版本。

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

在自动化编译过程中,如何修改产品的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值