现在的位置: 首页 > 综合 > 正文

installshield 安装脚本实例

2018年02月05日 ⁄ 综合 ⁄ 共 19555字 ⁄ 字号 评论关闭

实现的功能::

1.检测是否安装JDK,TOMCAT,MYSQL,APACHE HTTP,如果没安装,提示安装,否则中断

2.检测jdk版本

3.注册系统服务Tomcat/删除系统服务

4.设置环境变量

5.添加启动项

6.添加快捷方式


#include "ifx.h"


export prototype  installJDK() ;
export prototype  getJAVA_HOME();    
export prototype  installMysql();  
export prototype  installTomcat();
export prototype installHttp();
export prototype addFileValue(string,string,string,string);
string password,Java_Home;
/*-------------------------------------------------------------------*/
/*
安装JDK
*/
function installJDK()
string  szJDK,  szKey ,JDKversion ;
number  nType, nvSize;
begin
    // 查看是否已经安装了JDK,而且版本大于5.0
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SOFTWARE\\JavaSoft\\Java Development Kit";  
    nType = REGDB_STRING;  
    JDKversion = "";  
    // Get the list of subkeys.  
    RegDBGetKeyValueEx(szKey, "CurrentVersion", nType, JDKversion, nvSize);
    if(JDKversion < "1.5") then     
        if(AskYesNo ( "系统检测到您机器上未安装JDK或者JDK版本过低,会影响系统的正常使用。\n\n接下来将为您安装 JDK 6.0     \n\nJDK的版权归Sun公司所有 ...", YES )=YES) then
              szJDK =  SUPPORTDIR ^ "jdk-6-windows.exe";  
                 if (LaunchAppAndWait (szJDK, "", WAIT) < 0) then
                       MessageBox ("加载JDK失败,请手动安装JDK5.0或以上版本再运行此程序",SEVERE);
                       abort;
                     endif;
           else
                MessageBox("您取消了JDK的安装,这会使系统无法正常运行,\n\n所以本安装程序不会继续安装,将退出安装!",INFORMATION);
                abort;  
           endif;                
    endif;  
     JDKversion="";    
        RegDBGetKeyValueEx(szKey, "CurrentVersion", nType, JDKversion, nvSize);    
        if(JDKversion < "1.5") then
            MessageBox("系统检测到您未正常安装JDK,本程序将退出。\n\n您可以:\n\n1、手动安装JDK5.0或以上版本.\n\n2、重新运行本程序,按照提示安装JDK.",SEVERE);                    
        abort;
     endif;
end;
/*-----------------------------------------------------------------------------*/
function  installMysql()
string  szJDK,  szKey ,szDisplayName ;
number  nType, nvSize;
begin
    // 查看是否已经安装了Mysql
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SYSTEM\\CurrentControlSet\\Services\\MySQL";  
    nType = REGDB_STRING;  
    szDisplayName = "";  
    // Get the list of subkeys.  
    if(RegDBGetKeyValueEx(szKey, "DisplayName", nType, szDisplayName, nvSize)<0) then
        if(AskYesNo ( "系统检测到您机器上未安装Mysql,会影响系统的正常使用。\n\n接下来将为您安装 Mysql 5.0", YES )=YES) then
              szJDK =  SUPPORTDIR ^ "mysql Setup.exe";  
                 if (LaunchAppAndWait (szJDK, "", WAIT) < 0) then
                       MessageBox ("加载Mysql失败,请手动安装Mysql再运行此程序",SEVERE);
                       abort;
                     endif;
           else
                MessageBox("您取消了Mysql的安装,这会使系统无法正常运行,\n\n所以本安装程序不会继续安装,将退出安装!",INFORMATION);
                abort;  
           endif;                
    endif;
end;    
/*---------------------------------------------------------------------------*/
/*
  安装Tomcat
*/
function  installTomcat()
string  szJDK,  szKey ,szDisplayName ;
number  nType, nvSize;
begin
    // 查看是否已经安装了Tomcat
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SYSTEM\\CurrentControlSet\\Services\\Tomcat7";  
    nType = REGDB_STRING;  
    szDisplayName = "";  
    // Get the list of subkeys.  
    if(RegDBGetKeyValueEx(szKey, "DisplayName", nType, szDisplayName, nvSize)<0) then
        if(AskYesNo ( "系统检测到您机器上未安装Tomcat7,会影响系统的正常使用。\n\n接下来将为您安装 Tomcat7", YES )=YES) then
              szJDK =  SUPPORTDIR ^ "apache-tomcat-7.0.27.exe";  
                 if (LaunchAppAndWait (szJDK, "", WAIT) < 0) then
                       MessageBox ("加载Tomcat7失败,请手动安装Tomcat7再运行此程序",SEVERE);
                       abort;
                     endif;
           else
                MessageBox("您取消了Tomcat7的安装,这会使系统无法正常运行,\n\n所以本安装程序不会继续安装,将退出安装!",INFORMATION);
                abort;  
           endif;                
    endif;
end;    
/*---------------------------------------------------------------------------*/
/**
安装Apache Http
*/              
function installHttp()
    string  szJDK,  szKey ,szDisplayName ;
    number  nType, nvSize;  
    begin
    // 查看是否已经安装了Apache
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
     szKey = "SYSTEM\\CurrentControlSet\\Services\\Apache";  
    nType = REGDB_STRING;  
    szDisplayName = "";  
    // Get the list of subkeys.  
    if(RegDBGetKeyValueEx(szKey, "DisplayName", nType, szDisplayName, nvSize)<0) then
        if(AskYesNo ( "系统检测到您机器上未安装Apache,会影响系统的正常使用。\n\n接下来将为您安装 Apache,\n\n如果选择取消,将中断本次安装", YES )=YES) then
              szJDK =  SUPPORTDIR ^ "Apache HTTP Server.exe";  
                 if (LaunchAppAndWait (szJDK, "", WAIT) < 0) then
                       MessageBox ("加载Apache Http Server失败,请手动安装Apache Http Service再运行此程序",SEVERE);
                       abort;
                     endif;
           else
                MessageBox("您取消了Apache Http Server的安装,这会使系统无法正常运行,\n\n所以本安装程序不会继续安装,将退出安装!",INFORMATION);
                abort;  
           endif;                
    endif;
end;   
/*---------------------------------------------------------------------------*/  
/**
设置环境变量
*/
function getJAVA_HOME()
/*JAVA_HOME注册表参数*/
string szKey,JDKDir,nzVersion;
number nType,nvSize,szRoot;
begin
 /*JAVA_HOME加入环境变量*/  
 szRoot= HKEY_LOCAL_MACHINE;
 RegDBSetDefaultRoot(szRoot);
 szKey = "SOFTWARE\\JavaSoft\\Java Development Kit";
 nType = REGDB_STRING;
 RegDBGetKeyValueEx(szKey, "CurrentVersion", nType, nzVersion, nvSize);
 szKey=szKey+"\\"+nzVersion;
 RegDBGetKeyValueEx(szKey, "JavaHome", nType, JDKDir, nvSize);    
 Java_Home= JDKDir;
end;
/*--------------------------------------------------------------------------*/
function OnFirstUIBefore()
    number  nResult, nLevel, nSize, nSetupType;
    string  szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
    string  szName, szCompany, szTargetPath, szDir, szFeatures, szTargetdir;
    BOOL    bLicenseAccepted;
    string  szField0,szField1,szField2,svEdit0,svEdit1,svEdit2,svEdit3,svEdit4;  
    string  szJDK,svTomcat,svMySql,szKey ,szDisplayName,szFolder,szCmdLine,szSrcFile1;
    number  nType,nvSize;
    string test1,test2;     
    LIST list, listStartCopy;
begin    
   
    nSetupType = COMPLETE;    
    szName = "";
    szCompany = "";
    bLicenseAccepted = FALSE;  
    TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;
    szDir = TARGETDIR;                                           
    szSrcFile1 = "hospital\\";

// Beginning of UI Sequence
Dlg_Start:
 nResult = 0;
 
 /*安装JDK*/
 installJDK();  
 
 /* 获取JAVA_HOME*/
 getJAVA_HOME();
 
 /*安装Tomcat7*/
 /*installTomcat();*/
 /*安装apache http*/
 installHttp();
 
 /*安装Mysql数据库*/
 installMysql();       
         
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_SdRegisterUser:
    szMsg = "";
    szTitle = "";
    //{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)    
    nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
    //}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
    if (nResult = BACK) goto Dlg_SdWelcome;

 Dlg_SdShowDlgEdit2:
   // 查看是否已经安装了Mysql
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SYSTEM\\CurrentControlSet\\Services\\MySQL";  
    nType = REGDB_STRING;  
    szDisplayName = "";  
    // Get the list of subkeys.  
    if(RegDBGetKeyValueEx(szKey, "DisplayName", nType, szDisplayName, nvSize)<0) then
        if(AskYesNo("系统检测到您未正常安装Mysql数据库,会影响短信系统的正常使用。\n\n你可以:\n\n1、安装完本系统后手动安装Mysql数据库,并手动创建相应数据库!\n\n2、退出本系统的安装,重新安装本系统!\n\n继续安装请选择 是(Y),退出安装选择 否(N)!",YES)=YES) then

        else
            abort;
        endif;    
    else
            szTitle = "数据库信息";   
            szMsg    = "请更改相应的Mysql数据库用户名和数据库密码:";
            //szField0 ="bin目录路径";     
            szField1 = "用户名";   
            szField2 = "密码";   
           // svEdit0 = "C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin";
            svEdit1 = "root";   
            svEdit2 = "123456";           
            nResult = SdShowDlgEdit2(szTitle, szMsg,szField1,szField2, svEdit1,svEdit2);    
        if (nResult = BACK) goto Dlg_SdRegisterUser;   
         //SdShowMsg ("下面进行数据库初始化操作,请勿手动关闭弹出窗口!", TRUE);   
         //Delay(2);                 
         CopyFile(SUPPORTDIR ^ "CreateDB.sql","c:\\"^"CreateDB.sql");
         CopyFile(SUPPORTDIR ^ "hospital.sql","c:\\"^"hospital.sql");
         RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
        szKey = "SOFTWARE\\MySQL AB\\MySQL Server 5.0";
        nType = REGDB_STRING;  
        svMySql = "";
        if(RegDBGetKeyValueEx(szKey, "Location", nType, svMySql, nvSize) < 0) then

            MessageBox ("查找MySQL路径失败,系统不能继续安装", SEVERE);    
            abort;
        endif;
        szDir = svMySql + "bin";   
        test1="\"";
        test2="\"";
        svEdit0 = test1+szDir+test2;      
         //启动mysql                                     
         LaunchAppAndWait("net","start mysql",WAIT);                                                                                         
         szJDK =  SUPPORTDIR ^ "hospital.bat";
         svEdit3 =  "C:\\"^"CreateDB.sql";
         svEdit4 =  "C:\\"^"hospital.sql";
         LaunchAppAndWait(szJDK," " + svEdit0 + " " + svEdit1 + " " + svEdit2 + " " + svEdit3 + " " + svEdit4 + " ",WAIT);
         // 准备启动MySQL服务器    
         LaunchAppAndWait ("net","start mysql"   ,WAIT );  //启动MySQL
         password=svEdit2;
         DeleteFile("c:\\CreateDB.sql");
         DeleteFile("c:\\hospital.sql");
   endif;  
   /*    
    //查看Tomcat安装路径
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7";
    nType = REGDB_STRING;  
    svTomcat = "";
    if(RegDBGetKeyValueEx(szKey, "InstallPath", nType, svTomcat, nvSize) < 0) then

        MessageBox ("查找 Tomcat 路径失败,系统不能继续安装", SEVERE);   
        abort;  
    endif;           
    szDir = svTomcat + "\\webapps";
    MessageBox("正在准备Tomcat附加程序文件。。。",INFORMATION);
    CreateDir(szDir);                                                                
    if( CopyFile(SUPPORTDIR ^ "struts2.war",szDir+"\\struts2.war")<0)     
    then   
        MessageBox("程序文件附加失败!",SEVERE);
        abort;              
    else   
        MessageBox("程序文件已经附加成功!",INFORMATION);
    endif;
    */

Dlg_SetupType2:   
    szTitle = "";
    szMsg = "";
    nResult = CUSTOM;
    //{{IS_SCRIPT_TAG(Dlg_SetupType2)    
    nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
    //}}IS_SCRIPT_TAG(Dlg_SetupType2)
    if (nResult = BACK) then
        goto Dlg_SdRegisterUser;
    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_SdRegisterUser;
            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, TARGETDIR);
                //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
        //TARGETDIR = szDir;
    endif;
    if (nResult = BACK) goto Dlg_SetupType2;
    
/*Dlg_SQLServer:
    nResult = OnSQLServerInitialize( nResult );
    if( nResult = BACK ) goto Dlg_SdAskDestPath2;
*/
Dlg_ObjDialogs:
    nResult = ShowObjWizardPages( nResult );
    if (nResult = BACK) goto Dlg_SdAskDestPath2;
Dlg_SdStartCopy2:          
    szTitle = "";
    szMsg   = "";
    listStartCopy = ListCreate( STRINGLIST );
    //The following is an example of how to add a string(svName) to a list(listStartCopy).
    //eg. ListAddString(listStartCopy,svName,AFTER);   
    ListAddString(listStartCopy,"Destination Location: " + INSTALLDIR,AFTER);
    nResult = SdStartCopy( szTitle, szMsg, listStartCopy );            
    ListDestroy(listStartCopy);
    
    if (nResult = BACK) then
        goto Dlg_ObjDialogs;
    endif;

    // setup default status
    Enable(STATUSEX);
 
    return 0;
end;  
//---------------------------------------------------------------------------
// OnFirstUIAfter
//
// The OnFirstUIAfter event called by the framework after the file transfer
// of the setup when the setup is running in first install mode. By default
// this event displays UI that informs the end user that the setup has been
// completed successfully.
//---------------------------------------------------------------------------
function OnFirstUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
    NUMBER bOpt1, bOpt2,bStartService;  
    string szKey,svTomcat,szCmdLine,szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile,szStartServiceArgs;
    string szJDK,svEdit3,svEdit4,svEdit0,svEdit1,svEdit2;
    number nType,nvSize;   
    string JDKversion,svValue;
begin
    Disable(STATUSEX);

    bOpt1  = FALSE;
    bOpt2  = FALSE;
    szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
    SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);   
    
    
    /*-------------------------设置环境变量-------------------------------*/
    // 查看是否已经安装了JDK,而且版本大于5.0
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SOFTWARE\\JavaSoft\\Java Development Kit";  
    nType = REGDB_STRING;  
    JDKversion = "";  
    // Get the list of subkeys.  
    RegDBGetKeyValueEx(szKey, "CurrentVersion", nType, JDKversion, nvSize);
    szKey = "SOFTWARE\\JavaSoft\\Java Development Kit"+JDKversion;
    if (RegDBKeyExist(szKey)=1) then//如果该注册表值存在
        if(RegDBGetKeyValueEx(szKey,"JavaHome",nType,svValue,nvSize)=0) then//获取注册表值成功

            szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";

            if(RegDBSetKeyValueEx(szKey, "JAVA_HOME", REGDB_STRING, svValue, -1)<0) then

                MessageBox ("JAVA_HOME环境变量设置失败,请手动设置", SEVERE);
            endif;
        endif;
    endif;
    /*---------------------tomcat环境变量设置--------------------*/
    /*
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SYSTEM\\CurrentControlSet\\Services\\tomcat7";  
    nType = REGDB_STRING;  
    szDisplayName = "";  
    // Get the list of subkeys.  
    if (RegDBKeyExist(szKey)=1) then//如果该注册表值存在
        if(RegDBGetKeyValueEx(szKey,"JavaHome",nvType,svValue,nvSize)=0) then//获取注册表值成功

            szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";

            if(RegDBSetKeyValueEx(szKey, "CATALINA_HOME", REGDB_STRING, svValue, -1)<0) then

                MessageBox ("JAVA_HOME环境变量设置失败,请手动设置", SEVERE);
            endif;
        endif;
    endif;
    */
    //注册Tomcat7服务     
    /*
    //注册的服务名称
    szServiceName="tomcat7";

    //服务显示名称
    szServiceDisplayName="tomcat7";

    //服务描述
    szServiceDescription="tomcat服务";

    //程序文件的路径,安装路径下的Server目录下的test.exe文件
    szServicePathFile=TARGETDIR^"\\apache-tomcat7-web\\bin\\tomcat7.exe";
    MessageBox("exe路径:"+szServicePathFile,INFORMATION);         
    
    //启动类型为自动
    bStartService=0;

    szStartServiceArgs="";
    ServiceAddService ( szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, bStartService, szStartServiceArgs );
    ServiceStartService(szServiceName,"");         
    */
    /*
    // 准备启动TOMCAT服务器
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);   
    szKey = "SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7";
    nType = REGDB_STRING;  
    svTomcat = "";   
    if(RegDBGetKeyValueEx(szKey, "InstallPath", nType, svTomcat, nvSize) < 0) then

        MessageBox ("查找 Tomcat 路径失败,系统不能继续安装", SEVERE);     
    endif;  
    svTomcat = svTomcat + "\\bin\\tomcat7.exe";
    LaunchAppAndWait (svTomcat,"",NOWAIT);  //启动tomcat  
    */  
    szJDK =  SUPPORTDIR ^ "install.bat";
    svEdit0="\"";
    svEdit2="\"";   
    svEdit3 =  TARGETDIR^"\\apache-tomcat7-cas";
    svEdit4 =  TARGETDIR^"\\apache-tomcat7-service";
    svEdit1 =  TARGETDIR^"\\apache-tomcat7-web";//tomcat执行路径    
    
    svEdit3 =  svEdit0+svEdit3+svEdit2;
    svEdit4 =  svEdit0+svEdit4+svEdit2;
    svEdit1 =  svEdit0+svEdit1+svEdit2;
    Java_Home= svEdit0+Java_Home+svEdit2;  
    //MessageBox("java_home路径:"+Java_Home,INFORMATION);  
    //MessageBox("Tomcat路径:"+svEdit1,INFORMATION);
    LaunchAppAndWait(szJDK," " + Java_Home + " " + svEdit3 + " ",WAIT);
    szJDK =  SUPPORTDIR ^ "tomcat_service.bat";
    LaunchAppAndWait(szJDK," " + Java_Home + " " + svEdit4 + " ",WAIT);
    szJDK =  SUPPORTDIR ^ "tomcat_web.bat";
    LaunchAppAndWait(szJDK," " + Java_Home + " " + svEdit1 + " ",WAIT);
    // 准备启动MySQL服务器    
    //LaunchAppAndWait ("net","start tomcat7"   ,WAIT );  //启动MySQL
    MessageBox("Tomcat 已经启动成功!正在准备打开网页....",INFORMATION);
    //准备打开浏览器
    szCmdLine = "http://LocalHost:8380/struts2";
    if (LaunchApp(PROGRAMFILES ^"Internet Explorer"^"IEXPLORE.EXE", szCmdLine) < 0) then
        MessageBox ("不能打开浏览器.",SEVERE);
    endif;      

    // Added in 11.0 - Set appropriate StatusEx static text.
    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
    return 0;
end;   
 
//---------------------------------------------------------------------------
// OnMaintUIAfter
//
// The OnMaintUIAfter event called by the framework after the file transfer
// of the setup when the setup is running in maintenance mode. By default
// this event displays UI that informs the end user that the maintenance setup
// has been completed successfully.
//---------------------------------------------------------------------------
function OnMaintUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
    NUMBER bOpt1, bOpt2;  
    string szJDK,svEdit0,svEdit1,svEdit2,svEdit3,svEdit4;
begin

    Disable(STATUSEX);

    bOpt1   = FALSE;
    bOpt2   = FALSE;
    Dlg_Start:
    // Added - Version 9.5 - Use appropriate strings for complete
    // uninstall.
    if( REMOVEALLMODE ) then
        szTitle = SdLoadString(IFX_SDFINISH_REMOVE_TITLE);
        szMsg1 = SdLoadString(IFX_SDFINISH_REMOVE_MSG1);  
    else
        szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);    
        szMsg1  = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
    endif;

    SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
end;
//---------------------------------------------------------------------------
// OnMaintUIBefore
//
// The OnMaintUIBefore event is called by the framework when the setup is
// running in maintenance mode. By default this event displays UI that
// allows the end user to add or remove features, repair currently
// installed features or uninstall the application.
//---------------------------------------------------------------------------
function OnMaintUIBefore()
    NUMBER nResult, nType;
    STRING szTitle, szMsg, svDir, svResult, szCaption;
begin
    // TO DO: if you want to enable background, window title, and caption bar title                                   
    // SetTitle( @PRODUCT_NAME, 24, WHITE );                    
    // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );              
    // SetColor(BACKGROUND,RGB (0, 128, 128));                    
    // Enable( FULLWINDOWMODE );                        
    // Enable( BACKGROUND );                            
    
Dlg_Start:

    // Added in Version 9.5 - Support for REMOVEONLY option.
    if( !REMOVEONLY ) then
        // In standard mode show maintenance dialog
        Disable(BACKBUTTON);
        nType = SdWelcomeMaint(szTitle, szMsg, MODIFY);
        Enable(BACKBUTTON);
    else
        // Hide the initial progress dialog as otherwise the user can
        // click on it, and hide the MessageBox.
        Disable( DIALOGCACHE );

        // In RemoveOnly mode, set to remove.
        nType = REMOVEALL;
    endif;
    
    // Show Uninstall Confirmation Dialog
    if ( nType = REMOVEALL ) then
        nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );
        if (nResult != IDYES ) then
            
            if( REMOVEONLY ) then
                // In REMOVEONLY mode, abort the setup.
                abort;
            else
                // In non-REMOVEONLY mode, redisplay the previous dialog.
                goto Dlg_Start;
            endif;

        endif;
    endif;

    nResult = NEXT;

Dlg_SdFeatureTree:
    if (nType = MODIFY) then
        szTitle = "";
        szMsg = "";
        nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
        if (nResult = BACK) goto Dlg_Start;
    endif;

    switch(nType)
        case REMOVEALL: FeatureRemoveAll();                 
        /*-----------卸载tomcat7服务-------------------*/
        LaunchAppAndWait ( "", "sc stop tomcat7", LAAW_OPTION_HIDDEN );
         LaunchAppAndWait ( "", "sc delete tomcat7", LAAW_OPTION_HIDDEN );     
         /*-----------卸载tomcat8服务-------------------*/
         LaunchAppAndWait ( "", "sc stop tomcat8", LAAW_OPTION_HIDDEN );
         LaunchAppAndWait ( "", "sc delete tomcat8", LAAW_OPTION_HIDDEN );
         /*-----------卸载tomcat9服务-------------------*/
         LaunchAppAndWait ( "", "sc stop tomcat9", LAAW_OPTION_HIDDEN );
         LaunchAppAndWait ( "", "sc delete tomcat9", LAAW_OPTION_HIDDEN );
        case REPAIR:    FeatureReinstall();
    endswitch;
    
    // setup default status
    SetStatusWindow(0, "");
    Enable(STATUSEX);
    StatusUpdate(ON, 100);
end;         

function addFileValue(szFileName, szSectionName, szKeyName, szNewValue)
begin         
     if (AddProfString (szFileName, szSectionName, szKeyName,szNewValue) < 0) then
         MessageBox(szFileName+"文件配置失败,请手动更改"+szKeyName+"值为"+szNewValue, SEVERE);
     endif;                 
 end;       
//---------------------------------------------------------------------------
// OnMoved
//
// The OnMoved event is called just before the InstallShield action
// 'GeneratedMSIScript' is executed.
//---------------------------------------------------------------------------
function OnMoved()
begin          
    //配置文件  
    if(!MAINTENANCE)then
        addFileValue(TARGETDIR+"TomcatService.bat","","set CATALINA_HOME",TARGETDIR+"apache-tomcat7-cas");
    endif;         
end;
 
 

 

抱歉!评论已关闭.