---
title: "Installshield2008使用心得(打包web工程)"
author: "hipeace87"
date: "2008-12-15T11:59:14Z"
tags: ["MySQL", "Tomcat", "UI", "Web", "prototype"]
slug: "installshield2008-web"
draft: false
lastmod: "2008-12-15T11:59:14Z"
id: 293912
url: "https://hipeace87.iteye.com/blog/293912"
---

1.新建InstallScript Project 2.在Project Assistant 视图中填写Project的基本信息和文件及文件夹 3.InstallScript介绍()语法类似C; //以下的那些弹出窗口都可以在user interface --&gt;dialog中找到.可以修改. //user interface 下skin可改安装程序皮肤 #include "ifx.h" function OnFirstUIBefore()//执行安装程序的第一个窗口时执行 number nResult, nLevel, nSize, nSetupType; string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile; string szName, szCompany, szTargetPath, szDir, szFeatures; BOOL bLicenseAccepted; begin nSetupType = COMPLETE; szDir = TARGETDIR; szName = ""; szCompany = ""; bLicenseAccepted = FALSE; // Beginning of UI Sequence Dlg\_Start: nResult = 0; Dlg\_SdWelcome: szTitle = ""; szMsg = ""; //{{IS\_SCRIPT\_TAG(Dlg\_SdWelcome) nResult = SdWelcome( szTitle, szMsg );//弹出欢迎窗口 //}}IS\_SCRIPT\_TAG(Dlg\_SdWelcome) if (nResult = BACK) goto Dlg\_Start; Dlg\_SdLicense2: szTitle = ""; szOpt1 = ""; szOpt2 = ""; //{{IS\_SCRIPT\_TAG(License\_File\_Path) szLicenseFile = SUPPORTDIR ^ "License.rtf";//找一个名为license.rtf的文件(协议风容放在Support files/Billboards language independent下面) //}}IS\_SCRIPT\_TAG(License\_File\_Path) //{{IS\_SCRIPT\_TAG(Dlg\_SdLicense2) nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );//弹出协议窗口 //}}IS\_SCRIPT\_TAG(Dlg\_SdLicense2) if (nResult = BACK) then goto Dlg\_SdWelcome; else bLicenseAccepted = TRUE; endif; Dlg\_SdRegisterUser: szMsg = ""; szTitle = ""; //{{IS\_SCRIPT\_TAG(Dlg\_SdRegisterUser) //nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany ); //}}IS\_SCRIPT\_TAG(Dlg\_SdRegisterUser) if (nResult = BACK) goto Dlg\_SdLicense2; Dlg\_SetupType2: szTitle = ""; szMsg = ""; nResult = CUSTOM; //{{IS\_SCRIPT\_TAG(Dlg\_SetupType2) //nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 ); //SdShowDlgEdit1 (szTitle,szMsg,szDir,szTargetPath); //}}IS\_SCRIPT\_TAG(Dlg\_SetupType2) if (nResult = BACK) then goto Dlg\_SdLicense2; else nSetupType = nResult; if (nSetupType != CUSTOM) then szTargetPath = TARGETDIR; nSize = 0; FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize ); if (nSize != 0) then MessageBox( szSdStr\_NotEnoughSpace, WARNING ); goto Dlg\_SetupType2; endif; endif; endif; Dlg\_SdAskDestPath2: if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg\_SetupType2; szTitle = ""; szMsg = ""; if (nSetupType = CUSTOM) then //{{IS\_SCRIPT\_TAG(Dlg\_SdAskDestPath2) nResult = SdAskDestPath2( szTitle, szMsg, szDir ); //}}IS\_SCRIPT\_TAG(Dlg\_SdAskDestPath2) TARGETDIR = szDir; endif; if (nResult = BACK) goto Dlg\_SdLicense2; Dlg\_SdFeatureTree: if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg\_SdAskDestPath2; szTitle = ""; szMsg = ""; szFeatures = ""; nLevel = 2; if (nSetupType = CUSTOM) then //{{IS\_SCRIPT\_TAG(Dlg\_SdFeatureTree) //nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel ); //}}IS\_SCRIPT\_TAG(Dlg\_SdFeatureTree) if (nResult = BACK) goto Dlg\_SdAskDestPath2; endif; Dlg\_SQLServer: nResult = OnSQLServerInitialize( nResult ); if( nResult = BACK ) goto Dlg\_SdFeatureTree; Dlg\_ObjDialogs: nResult = ShowObjWizardPages( nResult ); if (nResult = BACK) goto Dlg\_SQLServer; Dlg\_SdStartCopy2: szTitle = ""; szMsg = ""; //{{IS\_SCRIPT\_TAG(Dlg\_SdStartCopy2) nResult = SdStartCopy2( szTitle, szMsg ); //}}IS\_SCRIPT\_TAG(Dlg\_SdStartCopy2) if (nResult = BACK) goto Dlg\_ObjDialogs; // Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS\_IFX\_STATUSEX\_STATICTEXT\_FIRSTUI ) ); return 0; end; //--------------------------------------------------------------------------- // OnBegin // // The OnBegin event is called directly by the framework after the setup // initializes. Note that this event will be called AFTER "Initialization" // events (i.e.) OnSetTARGETDIR, OnCheckMediaPassword. // // Note: This event will not be called automatically in a // program...endprogram style setup. //--------------------------------------------------------------------------- function OnBegin() //程序开始时执行 string szInfoString; begin //增加背景图片 szInfoString = SUPPORTDIR ^ "bbrd8.bmp" ; DialogSetInfo ( DLG\_INFO\_ALTIMAGE , szInfoString , TRUE); //设置安装程序时的桌面背景 Enable( BACKGROUND ); Enable(FULLWINDOWMODE); PlaceBitmap(SUPPORTDIR ^ "bbrd7.bmp",13,0,0,FULLSCREENSIZE); //SetDisplayEffect(EFF\_FADE) //PlaceBitmap(szInfoString,12,10,10,UPPER\_LEFT); end; //--------------------------------------------------------------------------- // OnEnd // // The OnEnd event is called at the end of the setup. This event is not // called if the setup is aborted. //--------------------------------------------------------------------------- 下面是执行系统批处理(注册mysql,tomcat服务)如何注册tomcat,mysql服务上一篇中已讲到 export prototype DefaultFeature\_Installed(); function DefaultFeature\_Installed() STRING myIniFile,baseDir,dataDir; STRING tomcatStart,mysqlStart; STRING BASEPATH,TEMP; NUMBER nSize,i; begin //设置mysql的my.ini配置文件的要根目录 //替换\\\\成/ BASEPATH = TARGETDIR; StrRemoveLastSlash(BASEPATH); nSize = StrLength(BASEPATH); i=0; while (i &lt; nSize) if (BASEPATH\[i] = "\\\\") then BASEPATH\[i] = "/"; endif; i = i + 1; endwhile; //处理完\\\\成/ myIniFile=BASEPATH+"/mysql5/my.ini"; baseDir= "basedir=\\""+BASEPATH+"/mysql5/\\""; dataDir="datadir=\\""+BASEPATH+"/mysql5/data/\\""; FileInsertLine (myIniFile,dataDir , 80, BEFORE); FileInsertLine (myIniFile,baseDir , 80, BEFORE); //注册mysql成系统服务 //ServiceAddService("OupuMysql222","OupuMysqlServer222","Mysql5021",TARGETDIR+"\\\\mysql5\\\\bin\\\\mysqld-nt.exe",TRUE,""); //启动mysql服务 //ServiceStartService("OupuMysql222",""); //调用 启动mysql.bat mysqlStart = TARGETDIR+"\\\\mysql5\\\\bin\\\\启动mysql.bat"; LaunchAppAndWait (mysqlStart,"",WAIT); //调用 启动tomcat.bat tomcatStart = TARGETDIR+"\\\\tomcat-5.5.20\\\\bin\\\\启动tomcat.bat"; LaunchAppAndWait (tomcatStart,"",WAIT); end; //--------------------------------------------------------------------------- // The UnInstalling event is sent just before the feature // DefaultFeature is uninstalled. //--------------------------------------------------------------------------- export prototype DefaultFeature\_UnInstalling(); function DefaultFeature\_UnInstalling() STRING tomcatStop,mysqlStop; begin //取消服务注册 //调用 启动mysql.bat mysqlStop = TARGETDIR+"\\\\mysql5\\\\bin\\\\停止mysql.bat"; LaunchAppAndWait (mysqlStop,"",WAIT); //ServiceRemoveService("OupuMysql222"); //调用 启动tomcat.bat tomcatStop = TARGETDIR+"\\\\tomcat-5.5.20\\\\bin\\\\停止tomcat.bat"; LaunchAppAndWait (tomcatStop,"",WAIT); end; 4.添加uninstall快捷方式郁闷了N久. 其实installshield本身已经自带uninstall程序.在你安装自己打包的程序时installshield会在C:\\Program Files\\下创建一个InstallShield Installation Information文件夹,下面再有一个{DE407BEB-F8AD-475F-AB69-73590C37D34F}的文件夹.DE407BEB-F8AD-475F-AB69-73590C37D34F是你程序的GUID 在General information--&gt;product property--&gt;product GUID可以看到..此文件夹下面有反安装程序.只要在setup动行的时候加一个 -uninst的参数就变成了卸载程序 知道这个就好办了.添加一个快捷方式.把路径指(target)定为\\InstallShield Installation Information\\{DE407BEB-F8AD-475F-AB69-73590C37D34F}\\Setup.exe,DE407BEB-F8AD-475F-AB69-73590C37D34F是你的GUID 自己手动替换一下.改一下Arguments参数为:/uninst