|
楼主 |
发表于 2006-4-25 11:05:30
|
显示全部楼层
Installscript工程脚本实例
<DIV style=\"LINE-HEIGHT: 22px; HEIGHT: 22px\" twffan=\"done\">
<DIV style=\"FLOAT: left\" twffan=\"done\"><IMG alt=发贴心情 src=\"http://installshield.jaron.cn/forum/skins/Default/topicface/face1.gif\" twffan=\"done\"></DIV><B>Installscript工程脚本实例</B></DIV>
<DIV style=\"ADDING-RIGHT: 0px; MARGIN-TOP: 10px; FONT-SIZE: 9pt; OVERFLOW-X: hidden; WIDTH: 97%; WORD-BREAK: break-all; TEXT-INDENT: 24px; LINE-HEIGHT: normal; HEIGHT: 200px; WORD-WRAP: break-word\" twffan=\"done\" onload=\"this.style.overflowX=\'auto\';\">
<> <BR>////////////////////////////////////////////////////////////////////////////////<BR>// <BR>// IIIIIII SSSSSS <BR>// II SS InstallShield (R) <BR>// II SSSSSS (c) 1996-2000, InstallShield Software Corporation <BR>// II SS (c) 1990-1996, InstallShield Corporation <BR>// IIIIIII SSSSSS All Rights Reserved. <BR>// <BR>// <BR>// This code is generated as a starting setup template. You should <BR>// modify it to provide all necessary steps for your setup.<BR>// <BR>// <BR>// File Name: Setup.rul <BR>// <BR>// Description: InstallShield script <BR>// <BR>// Comments: This template script performs a basic setup. With minor <BR>// modifications, this template can be adapted to create <BR>// new, customized setups.<BR>//<BR>////////////////////////////////////////////////////////////////////////////////</P>
<><BR>// Include header files<BR>//#define TITLE \"RegDBSetKeyValueEx & RegDBGetKeyValueEx\" <BR>#include \"ifx.h\" //DO NOT REMOVE<BR> <BR>////////////////////// string defines ////////////////////////////</P>
<>//////////////////// installation declarations ///////////////////</P>
<>// ----- DLL function prototypes -----<BR>#define SERIALNUM \"123456\"<BR>#define RES_DIALOG_ID 12027 // ID of Dialog itself <BR> // your DLL function prototypes</P>
<><BR>// ---- script function prototypes -----</P>
<><BR> // your script function prototypes<BR> prototype DialogShowSdFinishReboot();<BR> prototype SetupRegistry();</P>
<> // your global variables</P>
<> </P>
<>//////////////////////////////////////////////////////////////////////////////<BR>// <BR>// FUNCTION: OnFirstUIBefore <BR>// <BR>// EVENT: FirstUIBefore event is sent when installation is run for the first<BR>// time on given machine. In the handler installation usually displays<BR>// UI allowing end user to specify installation parameters. After this<BR>// function returns, ComponentTransferData is called to perform file<BR>// transfer.<BR>// <BR>///////////////////////////////////////////////////////////////////////////////<BR>function OnFirstUIBefore()<BR> NUMBER nResult,nSetupType;<BR> STRING szTitle, szMsg;<BR> STRING szLicenseFile, szQuestion;<BR> STRING svName, svCompany, svSerial;<BR> STRING szDir;<BR> STRING szfolder;<BR> STRING szComponents, szTargetdir;<BR> NUMBER nLevel; <BR> HWND hFont1; <BR> STRING szDialogName,szName,szCompany,szSerial,svSearchPath;<BR>begin <BR> // TO DO: if you want to enable background, window title, and caption bar title <BR> // SetTitle( @TITLE_MAIN, 24, WHITE ); <BR> // SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); <BR> // Enable( FULLWINDOWMODE ); <BR> // Enable( BACKGROUND ); <BR> // SetColor(BACKGROUND,RGB (0, 128, 128)); <BR> <BR> TARGETDIR = PROGRAMFILES <A href=\"mailto:^@COMPANY_NAME\" target=_blank>^@COMPANY_NAME</A> <A href=\"mailto:^@PRODUCT_NAME\" target=_blank>^@PRODUCT_NAME</A>; <BR> szDir = TARGETDIR;<BR> SHELL_OBJECT_FOLDER = @FOLDER_NAME;<BR> svName = \"\";<BR> svCompany = \"\";<BR> svSerial = \"\";</P>
<P><BR>Dlg_Start:<BR> // beginning of dialogs label</P>
<P>Dlg_SdWelcome:<BR> szDialogName = \"First_Dialog\"; <BR> EzDefineDialog (szDialogName, \"\", \"\", RES_DIALOG_ID);<BR> hFont1 = GetFont(\"宋体\", 9, STYLE_BOLD);</P>
<P> Enable( BACKGROUND );<BR> Enable ( FULLWINDOWMODE );<BR> PlaceBitmap ( SUPPORTDIR ^ \"setup2.bmp\" , 0 , 0 , 0 , FULLSCREEN ); <BR> <BR> szTitle = \"欢迎使用*****软件安装程序\"; <BR> SetFont (FONT_TITLE, STYLE_BOLD, szTitle);<BR> <BR> szMsg = \" 接下来将把*****软件安装到您的计算机上。\\n\\n 强烈建议在继续安装之前关闭其他正在运行的应用程序,这样会有助于在安装过程中避免任何冲突。\\n单击下一步继续,或取消退出安装。\";<BR> nResult = SdWelcome( szTitle, szMsg );<BR> <BR> if (nResult = BACK) goto Dlg_Start;<BR> DialogSetInfo(DLG_INFO_ALTIMAGE , SUPPORTDIR^\"Myinstall1.bmp\" , TRUE );<BR> if (nResult = BACK) goto Dlg_Start;</P>
<P>Dlg_SdLicense:<BR> nSetupType = TYPICAL; <BR> TARGETDIR = PROGRAMFILES <A href=\"mailto:^@COMPANY_NAME\" target=_blank>^@COMPANY_NAME</A> <A href=\"mailto:^@PRODUCT_NAME\" target=_blank>^@PRODUCT_NAME</A>; <BR> szDir = TARGETDIR;<BR> <BR> SHELL_OBJECT_FOLDER = @FOLDER_NAME;<BR> szLicenseFile = SUPPORTDIR ^ \"license.txt\";<BR> szTitle = \"许可协议\\n 请仔细阅读下面的重要信息,然后继续。\";<BR> szMsg = \" 请仔细阅读以下的许可协议,使用滚动条或Page Down键阅读协议的其余部分。\";<BR> szQuestion = \" 您接受上面协议所述的全部条款吗?如果您选择否,安装程序将会关闭。要继续安装*****软件,您必须接受这个协议。\";<BR> nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );<BR> if (nResult = BACK) goto Dlg_SdWelcome; <BR> <BR> //必须填入注册码的安装界面<BR>/*Dlg_SdRegisterUserEx:<BR> szName = \"\";<BR> szCompany = \"\";<BR> szSerial = \"\";<BR> szMsg = \" 您必须输入*****提供的*****软件产品序列号和正确的信息才能完成*****软件的安装。\";<BR> szTitle = \"使用者信息\"; <BR> nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial ); */<BR> <BR> <BR> //不用填入注册码的安装界面<BR> Dlg_SdRegisterUser:<BR> szName = \"\";<BR> szCompany = \"\";<BR> szSerial = SERIALNUM;<BR> //szMsg = \" 您必须输入*****提供的*****软件产品序列号和正确的信息才能完成*****软件的安装。\";<BR> szMsg =\"\";<BR> szTitle = \"使用者信息\"; <BR> nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany); <BR> <BR> //注册表中写入用户名称和公司名称,以供其他程序使用 <BR> RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );<BR> RegDBSetKeyValueEx( \"SoftWare\\\\AA\\\\BB\\\\用户信息\",<BR> \"用户名称\", REGDB_STRING,szName,-1);<BR> <BR> //if( nResult != BACK && szSerial != SERIALNUM ) then<BR> //MessageBox(\"序列号错误!请重新输入\",WARNING);<BR> //goto Dlg_SdRegisterUser; <BR> //nResult = 2;<BR> //endif;<BR> if (nResult = BACK) goto Dlg_SdLicense; </P>
<P>Dlg_SdAskDestPath:<BR> szTitle = \"选择目标文件夹\\n 准备把*****软件安装到哪里?\";<BR> szMsg = \" 请选择安装*****软件的文件夹,然后单击下一步继续。\";<BR> nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );<BR> TARGETDIR = szDir; <BR> RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );<BR> RegDBSetKeyValueEx( \"SoftWare\\\\AA\\\\BB\\\\用户信息\",<BR> \"Installpath\", REGDB_STRING,TARGETDIR,-1);<BR> if (nResult = BACK) goto Dlg_SdRegisterUser; <BR> <BR> <BR>Dlg_ObjDialogs:<BR> nResult = ShowObjWizardPages(nResult);<BR> if (nResult = BACK) goto Dlg_SdAskDestPath; <BR> <BR>Dlg_SdSelectFolder:<BR> szfolder = SHELL_OBJECT_FOLDER; <BR> szTitle = \"选择开始菜单文件夹\\n 程序快捷方式建立在哪里?\";<BR> szMsg = \" 选择开始菜单的一个文件夹,用来建立程序快捷方式,然后单击下一步继续。\"; <BR> nResult = SdSelectFolder( szTitle, szMsg, szfolder );<BR> SHELL_OBJECT_FOLDER = szfolder;<BR> if (nResult = BACK) goto Dlg_ObjDialogs;<BR> <BR> // setup default status<BR> SetStatusWindow(0, \"复制到...\"); <BR> Enable(STATUSDLG);<BR> PlaceWindow ( STATUSDLG , 350 , 200 , LOWER_RIGHT ); <BR> StatusUpdate(ON, 100); </P>
<P> return 0;<BR>end;</P>
<P>///////////////////////////////////////////////////////////////////////////////<BR>//<BR>// FUNCTION: OnMoving<BR>//<BR>// EVENT: Moving event is sent when file transfer is started as a result of<BR>// ComponentTransferData call, before any file transfer operations <BR>// are performed.<BR>//<BR>///////////////////////////////////////////////////////////////////////////////<BR>function OnMoving()<BR> string szAppPath;<BR> <BR>begin<BR> // Set LOGO Compliance Application Path <BR> // TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder <BR> szAppPath = TARGETDIR;<BR> RegDBSetItem(REGDB_APPPATH, szAppPath);<BR> RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY); <BR> <BR> <BR>end; </P>
<P>///////////////////////////////////////////////////////////////////////////////////<BR>//<BR>// FUNCTION: OnFirstUIAfter()<BR>// <BR>// <BR>// <BR>//<BR>///////////////////////////////////////////////////////////////////////////////<BR>function OnFirstUIAfter()<BR><BR>string szCmdLine;<BR>string szComponent;<BR>STRING svInfo, szInfo;<BR> NUMBER nReturn;<BR> STRING szTemp;<BR> NUMBER nvInfo, nInfo, nResult; <BR> string szMediaLibrary,svSearchPath;<BR> //STRING szKey, szPath, szRefDir; <BR> </P>
<P> <BR> STRING szKey, szNumName, szNumValue, svNumValue;<BR> NUMBER nType, nSize; <BR></P>
<P><BR>begin <BR> </P>
<P>szCmdLine = \"\"; </P>
<P><BR>//////////////////////////////////////////////////////////////////////////////////////////////</P>
<P>//注册ExcelAddin下的文件<BR>//ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\ExcelAddin\\\\</A>\"); <BR>//szCmdLine=\"-s ExcelAddin.dll\";<BR>//LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT); <BR><BR> <BR><BR>//注册iRTDB下的文件 <BR>ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iRTDB\\\\</A>\"); <BR>LaunchAppAndWait(\"regsvr2.bat\",\"\",WAIT);<BR> <BR> //050421添加,检测APC-Suite是不是已经安装过,如安装过,则不注册日志组件了<BR> RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);<BR> szKey=\"SOFTWARE\\\\SUPCON\\\\APC-Suite\\\\用户信息\";<BR> szNumName = \"installed\";<BR> szNumValue = \"1\";<BR> nType = REGDB_NUMBER;<BR> nSize = -1;<BR> if (RegDBGetKeyValueEx (szKey, szNumName, nType, szNumValue,nSize) < 0) then<BR> ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iRTDB\\\\</A>\"); <BR> szCmdLine=\"-s AdconLogMgtT.dll\";<BR> LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT); <BR> //ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iRTDB\\\\</A>\"); <BR> szCmdLine=\"-s AdconLogMgtpsT.dll\";<BR> LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT); <BR> <BR> endif;<BR><BR>//注册iMonitor下的文件<BR>ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iMonitor\\\\</A>\"); <BR>szCmdLine=\"-Service\";<BR>LaunchAppAndWait(\"MonitSer.exe\",szCmdLine,WAIT);<BR><BR>LaunchAppAndWait(\"start.bat\",\"\",WAIT);<BR> <BR>//注册iServer下的文件 <BR>ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iServer\\\\</A>\"); <BR>szCmdLine=\" -s OPCProxy.dll\";<BR>LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT);<BR><BR>szCmdLine=\" -RegServer\";<BR>LaunchAppAndWait(\"MQServer.exe\",szCmdLine,WAIT); <BR><BR>szCmdLine=\" -RegServer\";<BR>LaunchAppAndWait(\"MQWS.exe\",szCmdLine,WAIT); <BR><BR>szCmdLine=\" -RegServer\";<BR>LaunchAppAndWait(\"ADT.exe\",szCmdLine,WAIT); <BR><BR>//注册common下的文件 <BR>ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\common\\\\</A>\"); <BR>szCmdLine=\"-s UserDll.dll\";<BR>LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT);<BR><BR>szCmdLine=\"-s iTrend.ocx\";<BR>LaunchAppAndWait(\"regsvr32.exe\",szCmdLine,WAIT);</P>
<P> <BR>//设置环境变量和DCOM设置 <BR> ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iRTDB\\\\</A>\"); <BR> szTemp=TARGETDIR + \"<A>\\\\ExecFiles\\\\common\\\\</A>\";;<BR> szCmdLine=\" -s \" + \'\"\' + szTemp + \'\"\';<BR> LaunchAppAndWait(\"RegVariable.exe\", szCmdLine, WAIT);</P>
<P> szCmdLine=\" -InterUsr CTransfer.EXE\";<BR> LaunchAppAndWait(\"RegVariable.exe\", szCmdLine, WAIT); <BR> <BR> DialogShowSdFinishReboot(); <BR> end; <BR><BR>// --- include script file section ---</P>
<P><BR>///////////////////////////////////////////////////////////////////////////////<BR>//<BR>// FUNCTION: DialogShowSdFinishReboot()<BR>// <BR>// <BR>// //结束对话框 <BR>//<BR>///////////////////////////////////////////////////////////////////////////////</P>
<P>function DialogShowSdFinishReboot()<BR>NUMBER nResult, nDefOptions; <BR>STRING szMsg;<BR>STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;<BR>NUMBER bOpt1, bOpt2;<BR>begin<BR><BR>DialogSetInfo(DLG_INFO_ALTIMAGE , SUPPORTDIR^\"00install3.bmp\" , TRUE );<BR> szTitle = \"安装结束\";<BR> szMsg = \"安装结束!\";</P>
<P>if (!BATCH_INSTALL) then<BR>bOpt1 = FALSE;//不选<BR>bOpt2 = FALSE;//不选<BR>szTitle = \"安装完成\";<BR>szMsg1 = \"按完成键结束*****软件的安装。\";//%P代表安装程序名字。<BR>szMsg2 = \" \";//提示信息<BR>szOption2 = \"重新启动计算机。 \";<BR>nResult = SdFinishReboot( szTitle, szMsg1,nDefOptions, szMsg2, 0 );</P>
<P>return 0;<BR>endif;</P>
<P>nDefOptions = SYS_BOOTMACHINE;<BR>szTitle = \"\";<BR>szMsg1 = \"\";<BR>szMsg2 = \"\";<BR>nResult = SdFinishReboot( szTitle, szMsg1,nDefOptions, szMsg2, 0 );<BR>//由此控制决定是否重新启动计算机。</P>
<P>return nResult;<BR>end;</P>
<P><BR>//////////////////////////////////////////////////////////////////////////////<BR>//<BR>// FUNCTION: OnUninstallingFile<BR>//<BR>// EVENT: Uninstalling File event is sent before a file that is being uninstalled<BR>//<BR>// ARGUMENTS: File - full path of file being uninstalled<BR>//<BR>///////////////////////////////////////////////////////////////////////////////<BR>export prototype RTDB_UnInstalling();<BR>function RTDB_UnInstalling() <BR>string szTemp, szCmdLine,szKey,szKey1;<BR>begin<BR> ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iRTDB\\\\</A>\");<BR> LaunchAppAndWait(\"unregsvr2.bat\",\"\",WAIT);<BR><BR><BR> <BR> szTemp=TARGETDIR + \"<A>\\\\ExecFiles\\\\common\\\\</A>\";;<BR> szCmdLine=\" -u \" + \'\"\' + szTemp + \'\"\';<BR> LaunchAppAndWait(\"RegVariable.exe\", szCmdLine, WAIT); </P>
<P> ChangeDirectory(TARGETDIR^\"<A>\\\\ExecFiles\\\\iMonitor\\\\</A>\"); <BR> LaunchAppAndWait(\"Stop.bat\",\"\",WAIT); <BR> LaunchAppAndWait(\"unreg.bat\",\"\",WAIT);<BR> <BR> TARGETDIR = WINDIR;<BR> DeleteFile (\"Advplant.ini\");<BR><BR> <BR>end;</P></DIV> |
|