微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Installshield安装软件

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,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,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,"",nSetupType,0 );
    //SdShowDlgEdit1 (szTitle,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,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,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,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,FULLSCREENSIZE);  
    //SetdisplayEffect(EFF_FADE)
    //PlaceBitmap(szInfoString,12,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,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 @R_804_@R_502_6492@5@ion文件夹,下面再有一个{DE407BEB-F8AD-475F-AB69-73590C37D34F}的文件夹.DE407BEB-F8AD-475F-AB69-73590C37D34F是你程序的GUID 在General @R_804_@R_502_6492@5@ion-->product property-->product GUID可以看到..此文件夹下面有反安装程序.只要在setup动行的时候加一个 -uninst的参数就变成了卸载程序


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


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/deeplyloving/archive/2008/07/18/2673143.aspx

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐