//===========================================================================
//
// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h"
#define JRE_HOME TARGETDIR + "\\jre7"
#define CATALINA_HOME TARGETDIR
#define TOMCAT_SERVICE_PATH TARGETDIR + "\\bin\\service.bat"
#define SNTPServer '"'+TARGETDIR^"\\bin\\sntp_server\\sntp_server.exe "+'" '+'"'+"-service"+ '"'
#define RecordQueryService '"'+TARGETDIR^"\\bin\\RecordQueryService\\RecordQueryService.exe"+'" '+'"'+"-service"+ '"'
#define HIKCMS TARGETDIR^"\\bin\\tomcat7.exe \/\/RS\/\/HIKCMS"
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
begin
//判断系统环境,32位操作系统不允许安装
if(!SYSINFO.bIsWow64) then
MessageBox("此文件的版本与正在运行的Windows版本不兼容。请检查计算机的系统信息以了解需要x86(32位)还是x64(64位)版本的程序,然后联系软件发布者。",INFORMATION);
abort;
endif;
// Added in InstallShield 15 - Show an appropriate error message if
// -removeonly is specified and the product is not installed.
if( REMOVEONLY ) then
Disable( DIALOGCACHE );
szMsg = SdLoadString( IDS_IFX_ERROR_PRODUCT_NOT_INSTALLED_UNINST );
SdSubstituteProductInfo( szMsg );
MessageBox( szMsg, SEVERE );
abort;
endif;
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";
//}}IS_SCRIPT_TAG(License_File_Path)
//{{IS_SCRIPT_TAG(Dlg_SdLicense2)
nResult = SdLicense2Ex( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted, TRUE );
//}}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 );
//}}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_SetupType2;
endif;
endif;
endif;*/
Dlg_SdAskDestPath2:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdRegisterUser;
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_SdRegisterUser;
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;
#include "FeatureEvents.rul"
****************************************************************************************************************************************************************************
以下为FeatureEvents.rul文件的代码
****************************************************************************************************************************************************************************
#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff
//---------------------------------------------------------------------------
// The Installed event is sent after the feature cms\java
// is installed.
//---------------------------------------------------------------------------
export prototype java_Installed();
function java_Installed()
// string szKey, svPath;
// number nRegType, nvSize, pEnv, nvType, nRegSize;
begin
//tianjia JAVA_HOME 变量,并加到path路径下
//SetStatusExStaticText("正在配置JAVA运行环境...");
//RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
// nRegType = REGDB_STRING;
// nvSize = -1;
// if(RegDBKeyExist(szKey)= 1)then
// if (RegDBSetKeyValueEx (szKey, "JRE_HOME", nRegType, JRE_HOME, nvSize) < 0) then
// MessageBox ("JRE_HOME环境设置变量失败,请手动添加.", SEVERE);
// endif;
//endif;
//将JAVA_HOME加入环境变量PATH中
// if(RegDBGetKeyValueEx(szKey, "PATH", nRegType, svPath, nvSize)<0) then //判断PATH是否存在
// svPath = JRE_HOME+"\\jre\\bin";
// else
//判断一下这个路径下是否已经包含此路径了
// PathSet(svPath);
// PathDelete ("jre6\\bin", PARTIAL);
// PathGet(svPath);
// svPath = svPath + ";"+JRE_HOME+"\\bin";
//endif;
// Disable(LOGGING);
// if(RegDBSetKeyValueEx(szKey, "PATH", nRegType, svPath, -1)<0)then //设置注册表PATH
// MessageBox("PATH环境变量中增加jre失败,请手动添加!", SEVERE);
// endif;
//Enable(LOGGING);
//让环境变量生效
//PostMessage( HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
end;
//---------------------------------------------------------------------------
// The UnInstalled event is sent after the feature cms\java
// is uninstalled.
//---------------------------------------------------------------------------
export prototype java_UnInstalled();
function java_UnInstalled()
string szKey, szValue, svPath;
number nReturn, nRegType, nvSize;
begin
SetStatusExStaticText("正在卸载JAVA运行环境...");
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//取消JAVA_HOME环境变量
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
szValue = "JRE_HOME";
nRegType = REGDB_STRING;
nvSize = -1;
// Delete the subkey.
RegDBDeleteValue (szKey, szValue);
//修复PATH路径中的环境JAVA_HOME信息
// if(RegDBGetKeyValueEx(szKey, "PATH", nRegType, svPath, nvSize)=0) then //判断PATH是否存在
// PathSet(svPath);
// PathDelete ("jre6\\bin", PARTIAL);
// PathGet(svPath);
//
// if(RegDBSetKeyValueEx(szKey, "PATH", nRegType, svPath, -1)<0)then //设置注册表PATH
// MessageBox("PATH去掉jre环境路径失败,请手动删除!", SEVERE);
// endif;
// endif;
DeleteDir(TARGETDIR + "jre7", ROOT);
end;
//---------------------------------------------------------------------------
// The Installing event is sent just before the feature
// cms\tomcat is installed.
//---------------------------------------------------------------------------
export prototype tomcat_Installing();
function tomcat_Installing()
begin
SetStatusExStaticText("正在安装Web Server...");
// 停止和删除旧的CMS服务
ServiceStopService("HIKCMS");
ServiceRemoveService("HIKCMS");
end;
//---------------------------------------------------------------------------
// The Installed event is sent after the feature cms\tomcat
// is installed.
//---------------------------------------------------------------------------
export prototype tomcat_Installed();
function tomcat_Installed()
string szKey, svPath;
number nRegType, nvSize, pEnv, nvType, nRegSize;
string szinstallfile, szNewline;
number nvFileHandle;
begin
//安装加密狗运行必备组件VC_x86Runtime.exe
if ( LaunchAppAndWait(TARGETDIR^"vcredist_x64.exe", "/q", WAIT) < 0) then
if ( LaunchAppAndWait(TARGETDIR^"vcredist_x86.exe", "/q", WAIT) < 0) then
SprintfBox(MB_OK, "VC运行库安装", "安装VC_x86Runtime发生意外,请重新安装!");
abort;
endif;
endif;
LaunchAppAndWait(TARGETDIR^"jre-7u75-windows-x64.exe", "/s", LAAW_OPTION_HIDDEN|WAIT);
//添加CATALINA_HOME到系统环境变量
//SetStatusExStaticText("正在配置CATALINA_HOME运行环境信息");
//RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
//nRegType = REGDB_STRING;
//nvSize = -1;
// if(RegDBKeyExist(szKey)= 1)then
// if (RegDBSetKeyValueEx (szKey, "CATALINA_HOME", nRegType, CATALINA_HOME, nvSize) < 0) then
// MessageBox ("CATALINA_HOME添加环境变量失败,请手动添加.", SEVERE);
// endif;
// endif;
//安装CMS服务和配置相关运行参数
LaunchAppAndWait(TARGETDIR^"\\bin\\服务安装.bat", "", WAIT|LAAW_OPTION_HIDDEN);
ServiceAddService("HIKCMS","Apache Tomcat HIKCMS","Apache Tomcat HIKCMS",HIKCMS,TRUE,"");
//LaunchAppAndWait(TARGETDIR^"\\bin\\tomcat6w.exe", "", WAIT|LAAW_OPTION_HIDDEN);
ServiceAddService("SNTPServer","SNTPServer","SNTPServer",SNTPServer,TRUE,"");
ServiceAddService("RecordQueryService","RecordQueryService","RecordQueryService",RecordQueryService,TRUE,"");
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature
// cms\tomcat is uninstalled.
//---------------------------------------------------------------------------
export prototype tomcat_UnInstalling();
function tomcat_UnInstalling()
begin
SetStatusExStaticText("正在卸载Web Server...");
ServiceStopService("HIKCMS");
ServiceStopService("SNTPServer");
ServiceStopService("RecordQueryService");
ServiceRemoveService("HIKCMS");
ServiceRemoveService("SNTPServer");
ServiceRemoveService("RecordQueryService");
LaunchAppAndWait(TARGETDIR^"\\bin\\服务卸载.bat", "", WAIT|LAAW_OPTION_HIDDEN);
end;
//---------------------------------------------------------------------------
// The UnInstalled event is sent after the feature cms\tomcat
// is uninstalled.
//---------------------------------------------------------------------------
export prototype tomcat_UnInstalled();
function tomcat_UnInstalled()
string szKey, szValue, svPath;
number nReturn, nRegType, nvSize;
begin
SetStatusExStaticText("正在卸载Web Server...");
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
LaunchAppAndWait(TARGETDIR^"jre-7u75-windows-x64.exe", "/qu", LAAW_OPTION_HIDDEN|WAIT);
//取消JAVA_HOME环境变量
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
szValue = "CATALINA_HOME";
nRegType = REGDB_STRING;
nvSize = -1;
// Delete the subkey.
// RegDBDeleteValue (szKey, szValue);
DeleteDir(TARGETDIR^"\\logs", ALLCONTENTS);
DeleteDir(TARGETDIR^"\\bin", ALLCONTENTS);
DeleteDir(TARGETDIR^"\\temp", ALLCONTENTS);
DeleteDir(TARGETDIR^"\\webapps", ALLCONTENTS);
DeleteDir(TARGETDIR^"\\work", ALLCONTENTS);
DeleteDir(TARGETDIR, ALLCONTENTS);
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature
// cms\java is uninstalled.
//---------------------------------------------------------------------------
export prototype java_UnInstalling();
function java_UnInstalling()
begin
end;
//---------------------------------------------------------------------------
// The Installing event is sent just before the feature
// cms\java is installed.
//---------------------------------------------------------------------------
export prototype java_Installing();
function java_Installing()
begin
end;