Installshield2008使用心得(打包web工程)

1.新建InstallScript Project

2.在Project Assistant 视图中填写Project的基本信息和文件及文件夹

3.InstallScript介绍()语法类似C;

//以下的那些弹出窗口都可以在user interface -->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 < 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-->product property-->product GUID可以看到..此文件夹下面有反安装程序.只要在setup动行的时候加一个 -uninst的参数就变成了卸载程序


知道这个就好办了.添加一个快捷方式.把路径指(target)定为<PROGRAMFILES>\InstallShield Installation Information\{DE407BEB-F8AD-475F-AB69-73590C37D34F}\Setup.exe,DE407BEB-F8AD-475F-AB69-73590C37D34F是你的GUID 自己手动替换一下.改一下Arguments参数为:/uninst

你可能感兴趣的:(tomcat,Web,mysql,UI,prototype)