| / // //? File Name:??? Setup.rul // //? Description:? InstallShield script // //? Comments:???? This minimal project is intended for advanced users. //??????????????? To create a robust project with step-by-step //????? instructions, use the Project Wizard. // / // Include header files / #include "ifx.h" #include "CreateDB.Rul"?? #include "System.rul" #include "IIS.rul"??? #include "CustomPassword.Rul"? ??? // string defines #define DBSERVER "(local)"//數據庫服務器 #define WEBNAME "****.net" #define ****NetReg "****\\****.net" #define INSTALL_DB_FILE_DELETE "****.iss"?????? #define DBFILENAME1 "****.MDF"?? #define DBFILENAME2 "****.LDF"? installation declarations /// ??? // In order to have your InstallScript function executed as a custom ??? // action by the Windows Installer, it must be prototyped as an ??? // entry-point function. ??? // The keyword export identifies MyFunction() as an entry-point function. ??? // The argument it accepts must be a handle to the Installer database. ??? ????? /* export prototype MyFunction(HWND); */? ??? // To Do:? Declare global variables, define constants, and prototype? ??? //???????? defined and DLL functions here. // ----- DLL function prototypes ----- ??? // your DLL function prototypes // ---- script function prototypes ----- ??? // your script function prototypes ??? // your global variables //全局變量定義 STRING szSQLPATH, szDatabaseDestinationPath,svEdit1,szTemp,DBNAME; STRING? svServer, svUser, svPassword, svDBName; STRING? szVer,szParameter; BOOL bDeleteDB, bHaveOldDB, bHaveSql ; int i;? VARIANT SQLOBJ; NUMBER? nvFileHandle; /// //?????????????????????????????????????????????????????????????????????????? //? 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, sdResult, nSetupType; ??? NUMBER? nRootKey,nType, nSize,abc; ??? string? szTitle, szMsg; ??? string? szLicenseFile, szQuestion; ??? string? szDir; ??? LIST??? listStartCopy; ??? STRING szQuestion1, szQuestion2; begin ?//系統初始安裝過程? ?DBNAME="*"; ??? SetTitle( @COMPANY_NAME + " - " + @PRODUCT_NAME + "? 安裝向導", 24, WHITE ); ??? SetTitle( @COMPANY_NAME + " - " + @PRODUCT_NAME + "? 安裝向導", 0, BACKGROUNDCAPTION );???????????????????? ??? UNINSTALL_DISPLAYNAME = "*.net"; ??? SHELL_OBJECT_FOLDER = @PRODUCT_NAME; ??? ??? svServer = "localhost"; ??? svDBName = DBNAME; ??? ??? bHaveOldDB = FALSE; ??? bDeleteDB = FALSE; ??? ??? szDir = INSTALLDIR; Dlg_Start: ??? SdShowMsg("正在檢測操作系統版本...",TRUE); ?Delay(1); ?nResult = CheckSystem(2000); ? ?if ( nResult != 0 ) then ? switch( nResult ) ?? case 1: ??? szMsg = "請使用 windows 2000 版本及以上"; ?? case 2: ??? szMsg = "初始化檢測函數失敗"; ? endswitch; ? MessageBox(szMsg, SEVERE); ? abort; ?endif; ?? ?SdShowMsg("正在檢測 Internet 信息服務...", TRUE); ?Delay(1); ?nResult = CheckIIS(5); ? ?if ( nResult != 0 ) then ? switch ( nResult ) ???????? case 1: ????????? szMsg = "初始化檢測函數失敗"; ???????? case 2: ????????? szMsg = "本機沒安裝IIS"; ???????? case 3: ????????? szMsg = "本機 IIS 版本不是5及以上"; ? endswitch; ? MessageBox(szMsg, SEVERE); ? abort; ?endif; ? ?SdShowMsg("正在檢測 Microsoft DotNet Framework...",TRUE); ?Delay(2); ?nResult = CheckSystem(3705); ? ?if ( nResult != 0 ) then ? switch ( nResult ) ???????? case 1: ????????? szMsg = "初始化檢測函數失敗";? ??? MessageBox(szMsg, SEVERE); ??? abort; ???????? case 2: ????????? //szMsg = "本機沒安裝.NetFrameWork,請先安裝.NetFrameWork軟件包"; ????????? //運行.NetFrameWork安裝包??? ??? SdShowMsg("正在安裝 Microsoft DotNet Framework...",TRUE); ????????? if LaunchAppAndWait(SUPPORTDIR ^ "dotnetfx.exe", "", WAIT) < 0 then ??????? szMsg = "安裝.NetFrameWork軟件包出錯,請手工安裝!"; ????????? MessageBox(szMsg, SEVERE); ????????? abort; ??? endif; ??? SdShowMsg("成功安裝 Microsoft DotNet Framework...",TRUE); ??? Delay(2); ? endswitch; ?endif; ??????? ?SdShowMsg("正在檢測數據庫服務...", TRUE); ?Delay(1); ?nResult = CheckSQLServer(svServer, szSQLPATH, szDatabaseDestinationPath, 8); ?if ( nResult != 0 ) then ? switch( nResult ) ????? case 1: ?????? szMsg = "初始化檢測函數失敗"; ????? case 2: ?????? szMsg = "本機沒安裝SQL Server"; ????? case 3: ?????? szMsg = "本機SQL Server版本不是SQL Server 2000"; ????? case 4: ?????? szMsg = "無法檢測到SQL數據庫服務器安裝路徑"; ????? case 4: ?????? szMsg = "無法檢測到SQL數據庫文件存放路徑";????? ? endswitch; ? MessageBox(szMsg, SEVERE); ? abort; ?else ? bHaveSql=TRUE; ?endif; ??? SdShowMsg("...", FALSE); Dlg_SdWelcome: ?//顯示歡迎界面 ??? szTitle = "*.net"; ??? szMsg?? = "??? ***軟件發展有限公司 *.net 安裝向導將在計算機中安裝 *.net。 ????????????????若要繼續,請單擊“下一步”。"; ??? sdResult = SdWelcome( szTitle, szMsg ); ??? if (sdResult = BACK) goto Dlg_Start; Dlg_SdLicense: ?//顯示許可協議 ??? szLicenseFile = SUPPORTDIR ^ "許可協議.txt"; ??? szTitle??? = ""; ??? szMsg????? = ""; ??? szQuestion = ""; ??? sdResult??? = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile ); ??? if (sdResult = BACK) goto Dlg_SdWelcome; AskDatabasePwd: ?//詢問數據庫訪問密碼?? ??? SdShowMsg("正在檢測數據庫...", TRUE); ?Delay(1);????? ?? nResult= SdCustomPassword("PasswordDlh","??? 安裝程序需要SQL數據庫服務器 ??????????? "超級用戶權限,請輸入SQL數據庫服務器超級用戶登錄信息", ????????????"輸入SQL數據庫服務器超級用戶登錄信息","用? 戶","口? 令", ????????????svUser,svPassword); ?? if (nResult = BACK) goto Dlg_SdLicense; ?? SdShowMsg("安裝程序正在啟動SQL數據庫服務器...",TRUE); ?? SQLOBJ=CreateObject("SQLDMO.SQLServer"); ?? if IsObject(SQLOBJ) then ?? try? ??? try ???? SQLOBJ.Start(TRUE, "(local)",svUser,svPassword); ??? catch?????????????????????????????????? ???? SQLOBJ.Connect("(local)", svUser, svPassword);????? ??? endcatch;? ??? if !SQLOBJ.VerifyConnection then ????? MessageBox("SQL數據庫服務器不能啟動,安裝程序將退出!",SEVERE);?? ????? abort; ??? endif;???? ?? catch ????? MessageBox("SQL數據庫服務器不能啟動,安裝程序將退出!",SEVERE);?? ????? abort; ?? endcatch;?? ?? else ???? MessageBox("沒有找到SQL數據庫服務器,安裝程序將退出!",SEVERE);?? ???? abort; ?? endif;??? ?? SdShowMsg("...",FALSE);? ????????????? ?? bHaveSql=TRUE; ??????????? Dlg_InputDBName:??? ?? svEdit1=DBNAME;???? ?? // Get a target folder name from the user. ?? nResult=SdShowDlgEdit1 ("請輸入安裝數據庫名", "請輸入安裝數據庫名:", ? ???????????????????????? "數據庫名:", svEdit1); ?? if (nResult< 0) then ????? MessageBox ("創建對話窗口失敗!", SEVERE);?????????????????????? ?? elseif (nResult==BACK)then?? ????? goto AskDatabasePwd; ?? elseif(StrLength(svEdit1)==0) then ????? MessageBox ("數據庫名不能為空!", SEVERE);?????????????????????? ????? goto Dlg_InputDBName; ?? endif; ?? DBNAME=svEdit1; ?? //檢查數據庫是否存在 ? ??? for i=1 to SQLOBJ.Databases.Count ????? szTemp=SQLOBJ.Databases.Item(i).Name; ????? StrToUpper(szTemp,szTemp); ????? if (szTemp==svEdit1) then? ?????? MessageBox ("數據庫"+svEdit1+"已經存在,點擊“確定”繼續安裝, ???????????????????"不會對現有數據庫產生任何影響……", INFORMATION);?? ??????? /*if (AskYesNo("數據庫"+svEdit1+"已經存在,如果繼續, ???????????????????????"現存的數據庫將被刪除,是否繼續?",NO)==NO) then ????????? goto Dlg_InputDBName; ???????? else ?????????? bDeleteDB = TRUE; ???????? endif;*/ ????? endif; ??? endfor;???????? ??? if (sdResult = BACK) goto AskDatabasePwd; ????????? Dlg_SdAskVirtualDirectories: ?//詢問虛擬目錄 ??? if (sdResult = BACK) goto Dlg_SdAskVirtualDirectories; Dlg_SdAskDestPath:? ??? //讀取注冊表 ?/*nRootKey = HKEY_CURRENT_USER; ?if (RegDBSetDefaultRoot (nRootKey) < 0) then ???? MessageBox("初始化失敗", SEVERE); ?? else???????????????????????? ???? abc = RegDBGetKeyValueEx(****NetReg,"InstallPath",nType,szDir,nSize); ? if (abc < 0) then???? */ ????? szTitle = ""; ????? szMsg?? = ""; ????? sdResult = SdAskDestPath( szTitle, szMsg, szDir, 0 ); ????? INSTALLDIR = szDir; ????? if (sdResult = BACK) goto AskDatabasePwd; ? /*else ?? StrSub(szDir, szDir, 0, StrFind(szDir, "****.net")); ?? INSTALLDIR = szDir; ? endif; ?endif;? */ Dlg_SdStartCopy: ??? szTitle = ""; ??? szMsg?? = ""; ??? listStartCopy = ListCreate( STRINGLIST ); ??? ??? ListAddString(listStartCopy, "安裝組件:", AFTER); ??? ListAddString(listStartCopy, "\tWeb程序" , AFTER); ??? ListAddString(listStartCopy, "\t幫助文檔" , AFTER); ??? ListAddString(listStartCopy, "\t軟件狗驅動" , AFTER); ??? ListAddString(listStartCopy, "\t數據庫配置工具" , AFTER); ??? ListAddString(listStartCopy, "", AFTER); ??? ??? ListAddString(listStartCopy, "目標目錄:", AFTER); ??? ListAddString(listStartCopy, "\t" + INSTALLDIR , AFTER); ??? ListAddString(listStartCopy, "", AFTER); ??? ??? ListAddString(listStartCopy, "命令目錄:", AFTER); ??? ListAddString(listStartCopy, "\t***-****.net行業管理系統" , AFTER); ??? ListAddString(listStartCopy, "", AFTER); ??? ??? StrToUpper(szMsg, svDBName); ??? ListAddString(listStartCopy, "數據庫:", AFTER); ??? ListAddString(listStartCopy, "\t" + szMsg, AFTER); ??? ListAddString(listStartCopy, "", AFTER); ??? ??? ListAddString(listStartCopy, "虛擬目錄:", AFTER); ??? ListAddString(listStartCopy, "\t" + WEBNAME , AFTER); ??? ListAddString(listStartCopy, "\t本機使用 http://localhost/" + ????WEBNAME + " 進行訪問", AFTER); ??? ListAddString(listStartCopy, "", AFTER); ??? ??? szMsg = ""; ??? sdResult = SdStartCopy( szTitle, szMsg, listStartCopy ); ??? ListDestroy(listStartCopy); ??? if (sdResult = BACK) goto Dlg_SdAskDestPath; ??? Enable(STATUSEX); ??? return 0; end; /// // //? FUNCTION:?? OnFirstUIAfter // //? EVENT:????? FirstUIAfter event is sent after file transfer, when installation //????????????? is run for the first time on given machine. In this event handler //????????????? installation usually displays UI that will inform end user that //????????????? installation has been completed successfully. // ///? function OnFirstUIAfter() ??? STRING szTitle, szMsg, szMsg1, szMsg2, szOption1, szOption2; ??? NUMBER bOpt1, bOpt2, nResult, nType, nSize; ??? NUMBER nRootKey, SQLVersion;???? ?? STRING szTemp,svResult, svTime, ProductVersion; begin ? ?/*SdShowMsg("安裝軟件狗驅動...", TRUE); ??? nResult = InstallDogDriver(); ??? if ( nResult != 0 ) then ??? MessageBox("安裝軟件狗驅動程序失敗,請手工安裝軟件狗驅動程序!\n" ????????????? +'手工安裝,請執行'+INSTALLDIR ^ '\\****\\ ??????????????軟件狗驅動程序\\****.exe',SEVERE); ??? endif; */ ?????????? ??? SdShowMsg("安裝產品數據庫...", TRUE); ??? if (bDeleteDB) then ??????? nResult = DeleteDatabase(svDBName); ??????? if ( nResult != 0 ) then ?? szMsg = "刪除舊數據庫失敗"; ?? MessageBox(szMsg, SEVERE); ???? endif; ??? endif; ? Disable(STATUSEX);????????????? ? OpenFileMode (FILE_MODE_APPEND); ? //創建數據庫安裝文件 ? if (CreateFile (nvFileHandle, SUPPORTDIR, INSTALL_DB_FILE_DELETE) < 0) then ???? MessageBox ("創建文件失敗!", SEVERE); ???? abort; ? else ???? szMsg = "declare @dttm varchar(55) \n" ?????????? +"select? @dttm=convert(varchar,getdate(),113)\n" ?????????? +"raiserror('Beginning InstPubs.SQL at %s ....',1,1, ???????????@dttm) with nowait \n" ?????????? +"GO \n" ?????????? +"use master \n" ?????????? +"go \n" ?????????? +"raiserror('Creating "+svEdit1+" database....',0,1) \n" ?????????? +"go \n" ??? ?????????? +" sp_attach_db '"+svEdit1+"',@filename1='"+ ???????????INSTALLDIR+"****.net\\DataBase\\"+DBFILENAME1+"',"+"@filename2='" ???????????+INSTALLDIR+"****.net\\DataBase\\"+DBFILENAME2+"' \n" ?????????? +"go\n"; ???? if (WriteLine(nvFileHandle, szMsg) < 0) then ??????? MessageBox("寫入文件發生錯誤!", SEVERE); ??????? abort; ???? endif; ?? endif; ?? CloseFile (nvFileHandle); ?? szParameter=" -U "+svUser+" -P "+svPassword+" -i "+ ???SUPPORTDIR+INSTALL_DB_FILE_DELETE+" -o c:\\Errlog.txt -n"; ?? if bHaveSql then ??? SdShowMsg("開始安裝數據庫,請等待...",TRUE); ??? Delay(5); ??? szSQLPATH=INSTALLDIR^"****.net\\DataBase\\OSQL.EXE"; ??? if LaunchAppAndWait(szSQLPATH,szParameter,WAIT)<0 then ????? MessageBox("安裝數據庫失敗,請手工安裝數據庫!",SEVERE); ??? endif;????? ???? SdShowMsg("...",FALSE); ??? endif;?? ??? if LaunchAppAndWait(INSTALLDIR ^ "****.net\\bin\\tools\\****.exe", ????"", NOWAIT) < 0 then ???? szMsg = "運行數據庫配置工具出錯,請手工安裝!"; ?????? MessageBox(szMsg, SEVERE); ?endif;? ???????????? ??? if LaunchAppAndWait(SUPPORTDIR ^ "iewebcontrols.msi", "", WAIT) < 0 then ???? szMsg = "安裝瀏覽器組件出錯,請手工安裝!"; ?????? MessageBox(szMsg, SEVERE); ?endif; ????????????? ??? //修改注冊表 ?nRootKey = HKEY_CURRENT_USER; ?if (RegDBSetDefaultRoot (nRootKey) < 0) then ???? MessageBox("初始化失敗", SEVERE); ?? endif; ??? nType = REGDB_STRING; ?? ?? ProductVersion = @PRODUCT_VERSION; ?? ? RegDBSetKeyValueEx(****NetReg,"DatabaseName",nType,svDBName,nSize); ? RegDBSetKeyValueEx(****NetReg,"InstallPath",nType,INSTALLDIR^"****.net",nSize); ?? ? //StrSub(svResult, ProductVersion, 0, StrFind(ProductVersion, ".")); ? //StrSub(ProductVersion, ProductVersion, (StrFind(ProductVersion, ".") + 1),? ??(StrLength(ProductVersion) - StrFind(ProductVersion, "."))); ? RegDBSetKeyValueEx(****NetReg,"Ver",nType,ProductVersion,nSize); ?? GetSystemInfo (DATE, nResult, svResult); ?? svTime = svResult; ?? GetSystemInfo (TIME, nResult, svResult); ?? svTime = svTime + " " + svResult; ? RegDBSetKeyValueEx(****NetReg,"Date",nType,svTime,nSize);? ??????????? ?Disable(STATUSEX); ??? szTitle = ""; ??? szMsg1 = SdLoadString(IFX_SDFINISH_MSG1); ??? szMsg1 = szMsg1 + "\n\n客戶端訪問請使用 IE 6.0 及以上版本!"; ?szMsg2 = ""; ??? szOption1 = ""; ??? szOption2 = ""; ??? bOpt1? = FALSE; ??? bOpt2? = FALSE; ??? SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2); end; // --- include script file section --- ? ? |