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
轉載于:https://www.cnblogs.com/wanbinghong/archive/2010/09/01/1814800.html
總結
以上是生活随笔為你收集整理的InstallShield安装打包编译自动化(3)- 更新Package GUID,Product GUID以及Upgrade GUID的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设计模式札记——单例模式(Singlet
- 下一篇: 求一个整数n对16求商和余数