InstallShield安装脚本(供大家使用)(0分)

  • 主题发起人 spymaster
  • 开始时间
S

spymaster

Unregistered / Unconfirmed
GUEST, unregistred user!
总结前人经验,做了一个安装程序,这是脚本,希望对大家有帮助。
////////////////////////////////////////////////////////////////////////////////
//
// 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 SetupFolders();
prototype Pdkey(STRING);
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 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 ^@COMPANY_NAME ^@PRODUCT_NAME;
szDir = TARGETDIR;
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_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,szName,AFTER);
//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,"安装路径:"+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_ObjDialogs;
// 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: 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;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: Pdkey(key)
//
// EVENT: Test SerialKey
//
//////////////////////////////////////////////////////////////////////////////
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()
//
// EVENT: Regist key
//
//////////////////////////////////////////////////////////////////////////////
function SetupRegistry()
STRING szParent,szMsg;
begin
//注册系统信息
if (ComponentIsItemSelected(MEDIA,"账务系统") ) then
szParent="SOFTWARE//佳境科技//佳境音像管理系统";
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( szParent , "Installed" , REGDB_STRING , "True" , -1 );
RegDBSetKeyValueEx ( szParent , "server" , REGDB_STRING , "server" , -1 );
RegDBSetKeyValueEx ( szParent , "user" , REGDB_STRING , "sa" , -1 );
RegDBSetKeyValueEx ( szParent , "password" , REGDB_STRING , "" , -1 );
//注册SQLServer信息
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//DB-Lib//", "AutoAnsiToOem" , REGDB_STRING , "ON" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//DB-Lib//", "UseIntlSettings" , REGDB_STRING , "ON" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//ConnectTo//", "DSQUERY" , REGDB_STRING , "DBNMPNTW" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//ConnectTo//", "storesvr" , REGDB_STRING , "DBMSSOCN,127.0.0.1,1433" , -1 );//不用改
//BDE信息
RegDBSetKeyValueEx ( "SOFTWARE//Borland//Database Engine//Settings//DRIVERS//MSSQL//INIT//" , "CONNECT TIMEOUT" , REGDB_STRING , "5" , -1 );//不用改
endif;
SdShowMsg(szMsg,FALSE);
return 0;
end;

// --- include script file section ---
///////////////////////////////////////////////////////////////////////////////
//
// 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()
number nResult;
string szProgram,szUninstall,szResult;
begin
//卸载
szUninstall="C://Program Files//InstallShield Installation Information//{86BFF3ED-C576-473B-BB7A-5AF643F2286A}//Setup.exe";

LongPathToQuote (szUninstall, TRUE);

if(FindFile("C://Program Files//InstallShield Installation Information//{86BFF3ED-C576-473B-BB7A-5AF643F2286A}","Setup.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","卸载 佳境音像处理系统",szUninstall,TARGETDIR^"MANAGER","", 0,"", REPLACE);
endif;
//系统应用
szProgram=TARGETDIR^"MANAGER//VCDLEASE.exe";
LongPathToQuote (szProgram, TRUE);

if(FindFile(TARGETDIR^"MANAGER","VCDLEASE.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","佳境音像处理系统",szProgram,TARGETDIR^"MANAGER","", 0,"", REPLACE);
//桌面
AddFolderIcon(FOLDER_DESKTOP,"佳境音像处理系统",szProgram,TARGETDIR^"MANAGER","",0,"",REPLACE);
endif;
//帮助文件
szProgram=TARGETDIR^"MANAGER//HELP//VCDHELP.CHM";

LongPathToQuote (szProgram, TRUE);
if(FindFile(TARGETDIR^"MANAGER//HELP","VCDHELP.CHM",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","联机帮助",szProgram,TARGETDIR^"MANAGER//HELP","", 0,"", REPLACE);
endif;
//数据管理
szProgram=TARGETDIR^"DBMA//DBMA.exe";

LongPathToQuote (szProgram, TRUE);
if(FindFile(TARGETDIR^"DBMA","DBMA.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","后台数据管理工具",szProgram,TARGETDIR^"DBMA","", 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();
szMsg="正在创建快捷方式......";
SdShowMsg(szMsg,TRUE);
SetupFolders();
SdShowMsg(szMsg,FALSE);
return 0;
end;

 
有没有wise的安装脚本呀?装了个wise 9但是不会用
 
接受答案了.
 
顶部