这是我在网上搜集到的一篇《InstallShield6.22安装脚本文件样例》,你看能否有些帮助。
全文如下:
////////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
// Comments: This script was generated based on the selections you made in
// the Project Wizard. Refer to the help topic entitled "Modify
// the script that the Project Wizard generates" for information
// on possible next steps.
//
////////////////////////////////////////////////////////////////////////////////
// Include header files
#include "ifx.h"
////////////////////// string defines ////////////////////////////
//////////////////// installation declarations ///////////////////
// ----- DLL function prototypes -----
// your DLL function prototypes
// ---- script function prototypes -----
// your script function prototypes
prototype Pdkey(STRING);
prototype SetupFolders();
prototype SetupRegistry();
// your global variables
STRING szmserial1,szmserial2,szmserial3,szmserial4,szmserial5;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
number nResult,nSetupType;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany, szSerial;
string szFile;
string szTargetPath;
string szDir;
string szfolder;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
LIST list;
number nvSize,rc;
begin
// TOdo
: if you want to enable background, window title, and caption bar title
// SetTitle( @TITLE_MAIN, 24, WHITE );
// SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));
nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^"KYKQ";
szDir = TARGETDIR;
SHELL_OBJECT_FOLDER = @FOLDER_NAME;
szName = "";
szCompany = "";
szSerial = "";
Dlg_Start:
// begin
ning of dialogs label
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;
Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdShowInfoList:
szFile = SUPPORTDIR ^ "infolist.txt";
list = ListCreate( STRINGLIST );
ListReadFromFile( list, szFile );
szTitle = "";
szMsg = "";
nResult = SdShowInfoList( szTitle, szMsg, list );
ListDestroy( list );
if (nResult = BACK) goto Dlg_SdLicense;
Dlg_SdRegisterUserEx:
szMsg = "";
szTitle = "";
nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );
rc=Pdkey(szSerial);
if (( rc!=1) &&
(nResult != BACK)) then
MessageBox ( "序列号输入错误" , WARNING );
goto Dlg_SdRegisterUserEx;
else
if (nResult = BACK) then
goto Dlg_SdShowInfoList;
endif;
endif;
Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto Dlg_SdRegisterUserEx;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType ( szTitle , szMsg , "" , nSetupType , 0 );
if (nResult = BACK) then
goto Dlg_SdAskDestPath;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nvSize = 0;
ComponentCompareSizeRequired(MEDIA,szTargetPath,nvSize);
if (nvSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType;
endif;
endif;
endif;
Dlg_SdComponentTree:
if ((nResult = BACK) &&
(nSetupType != CUSTOM)) goto Dlg_SetupType;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
if (nResult = BACK) goto Dlg_SetupType;
endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages(nResult);
if (nResult = BACK) goto Dlg_SdComponentTree;
Dlg_SdSelectFolder:
szfolder = SHELL_OBJECT_FOLDER;
szTitle = "";
szMsg = "";
nResult = SdSelectFolder( szTitle, szMsg, szfolder );
SHELL_OBJECT_FOLDER = szfolder;
if (nResult = BACK) goto Dlg_ObjDialogs;
Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
ListAddString(listStartCopy,"你的选择如下:",AFTER);
ListAddString(listStartCopy,"/n",AFTER);
ListAddString(listStartCopy,"用户名:"+szName,AFTER);
ListAddString(listStartCopy,"公司名称:"+szCompany,AFTER);
ListAddString(listStartCopy,"/n",AFTER);
ListAddString(listStartCopy,"安装路径:"+TARGETDIR,AFTER);
ListAddString(listStartCopy,"/n",AFTER);
ListAddString(listStartCopy,"程序组名:"+SHELL_OBJECT_FOLDER,AFTER);
ListAddString(listStartCopy,"/n",AFTER);
if (nSetupType = CUSTOM) then
ListAddString(listStartCopy,"安装类型:"+"自定义",AFTER);
else
if (nSetupType = TYPICAL) then
ListAddString(listStartCopy,"安装类型:"+"典型",AFTER);
else
if (nSetupType = COMPACT) then
ListAddString(listStartCopy,"安装类型:"+"压缩",AFTER);
endif;
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_SdSelectFolder;
// setup default status
SetStatusWindow(0, "");
Enable(STATUSEX);
StatusUpdate(ON, 100);
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
string szAppPath,szUncmd;
int iPos;
begin
// Set LOGO Compliance Application Path
// TOdo
: if your application .exe is in a subfolder of TARGETDIR then
add subfolder
szAppPath = TARGETDIR;
RegDBSetItem(REGDB_APPPATH, szAppPath);
RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
szUncmd = "UNINSTALL_CMD";
iPos = StrFind(UNINSTALL_STRING,szUncmd);
if iPos>0 then
UNINSTALL_STRING[iPos - 1]='/0';
UNINSTALL_STRING=UNINSTALL_STRING + ",LaunchSetup /"" + DISK1TARGET+"//setup.exe/"";
MaintenanceStart();
endif;
end;
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoved
//
// EVENT: Moved event is sent when file transfer started by ComponentTransferData call
// has finished. At this point all file transfer operations are completed
// except for batch self-registration which is performed immediately after this
// function returns. During uninstallation this event sent after uninstallation
// is completed. For that reason you should not modify system state in this
// event handler.
//
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: Onbegin
//
// EVENT: begin
event is always sent as the first event during installation.
//
//////////////////////////////////////////////////////////////////////////////
function Onbegin
()
begin
szmserial1="0910-3256021-111";
szmserial2="0910-3254321-71301";
szmserial3="0910-3254321-71311";
szmserial4="0910-860023-111";
szmserial5="1111-111111-111";
end;
// --- include script file section ---
function Pdkey(key)
NUMBER rc;
begin
rc=0;
if key = szmserial1 then
rc=1;
goto rc_no;
endif;
if key = szmserial2 then
rc=1;
goto rc_no;
endif;
if key = szmserial3 then
rc=1;
goto rc_no;
endif;
if key = szmserial4 then
rc=1;
goto rc_no;
endif;
if key = szmserial5 then
rc=1;
endif;
rc_no:
return rc;
end;
function SetupRegistry()
STRING szDBprofile,szDB,szDriver,szDriver1,szSetup,szDBFile;
STRING szAccess,szAsa70,szAsasource,szAsasource_name;
STRING szMStranslator,szMStransdriver;
STRING szStart,szAsa70app;
STRING szCommand, szCmdLine,szMsg;
begin
//注册ASA70数据库
if (ComponentIsItemSelected(MEDIA,"ASA7.0") ) then
szAsa70app="SOFTWARE//Sybase//Adaptive Server Anywhere//7.0";
szDBprofile="kykq";
szDB="SOFTWARE//ODBC//ODBC.INI//"+szDBprofile;
szDBFile = TARGETDIR+"//database//kykq.db";//law.db的全名
szDriver = TARGETDIR+"//asa7.0//dbodbc7.dll";
szDriver1=TARGETDIR+"//asa7.0//dbodtr7.dll";
szAccess="Adaptive Server Anywhere 7.0";
szAsa70="Adaptive Server Anywhere 7.0 Translator";
szStart= TARGETDIR+"//asa7.0//dbeng7.exe -c 8m";
szAsasource="SOFTWARE//ODBC//ODBC.INI//ODBC Data Sources";
RegDBSetDefaultRoot ( HKEY_CURRENT_USER );
RegDBSetKeyValueEx ( szDB , "AutoStop" , REGDB_STRING , "YES" , -1 );
RegDBSetKeyValueEx ( szDB , "DatabaseFile" , REGDB_STRING , szDBFile , -1 );
RegDBSetKeyValueEx ( szDB , "Debug" , REGDB_STRING , "NO" , -1 );
RegDBSetKeyValueEx ( szDB , "DisableMultiRowFetch" , REGDB_STRING , "NO" , -1 );
RegDBSetKeyValueEx ( szDB , "Driver" , REGDB_STRING , szDriver , -1 );
RegDBSetKeyValueEx ( szDB , "Integrated" , REGDB_STRING , "NO" , -1 );
RegDBSetKeyValueEx ( szDB , "PWD" , REGDB_STRING , "sql" , -1 );
RegDBSetKeyValueEx ( szDB , "UID" , REGDB_STRING , "dba" , -1 );
RegDBSetKeyValueEx ( szDB , "Start" , REGDB_STRING , szStart, -1 );
RegDBSetKeyValueEx ( szAsasource,szDBprofile, REGDB_STRING , szAccess, -1 );
//注册ASA70 ODBC Driver
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//"+szAccess , "Driver" , REGDB_STRING , szDriver , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//"+szAccess , "Setup" , REGDB_STRING , szDriver , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//"+szAsa70 , "Driver" , REGDB_STRING , szDriver1 , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//"+szAsa70 , "Setup" , REGDB_STRING , szDriver1 , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//"+szAsa70 , "Translator" , REGDB_STRING , szDriver1 , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//ODBC Drivers" , szAccess , REGDB_STRING , "Installed" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//ODBC//ODBCINST.INI//ODBC Translators" , szAsa70 , REGDB_STRING , "Installed" , -1 );//不用改
//注册ASA70APP
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( szAsa70app , "Language" , REGDB_STRING , "ZH" , -1 );
RegDBSetKeyValueEx ( szAsa70app , "Location" , REGDB_STRING , TARGETDIR+"//asa70" , -1 );
RegDBSetKeyValueEx ( szAsa70app , "Shared Location" , REGDB_STRING , TARGETDIR+"//asa70" , -1 );
endif;
SdShowMsg(szMsg,FALSE);
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
//
// Function: SetupFolders
//
// Purpose: This function creates all the folders and shortcuts for the
// setup. This includes program groups and items for Windows 3.1.
//
///////////////////////////////////////////////////////////////////////////////
function SetupFolders()
string szPath,szResult,szhelpexe,szUninstallexe;
begin
if(FindFile(TARGETDIR,"kykq.EXE",szResult)=0) then
szPath=TARGETDIR^"kykq.exe";
LongPathToQuote(szPath,TRUE);
AddFolderIcon(SHELL_OBJECT_FOLDER,"中铁考勤管理系统",szPath,TARGETDIR,"",0,"",REPLACE);
AddFolderIcon(FOLDER_DESKTOP,"中铁考勤管理系统",szPath,TARGETDIR,"",0,"",REPLACE);
endif;
return 0;
end;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoved
//
// EVENT: Moved event is sent when file transfer started by ComponentTransferData call
// has finished. At this point all file transfer operations are completed
// except for batch self-registration which is performed immediately after this
// function returns. During uninstallation this event sent after uninstallation
// is completed. For that reason you should not modify system state in this
// event handler.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoved()
STRING szMsg;
begin
szMsg="正在更新注册表......";
SdShowMsg(szMsg,TRUE);
SetupRegistry();
SetupFolders();
SdShowMsg(szMsg,FALSE);
return 0;
end;