Make ASP, ASP.NET app installed using InstallShield

xiaoxiao2021-03-06  61

When using the ASP, ASP.NET write web applications, the biggest trouble is more deployed by the program. Due to the end user, the process of the program is installed must be simple, convenient and fast. The following is provided below, and the upgrading this feature includes: 1. Detect IIS to install 2, detect IE version 3, automatically establish SQL database 4, automatically establish IIS virtual directory 5, read registry and INI file 6, register. DLL Component Application Development Environment: Windows2000 VS 2003 SQL2000 Maker Environment: InstallShield 7.0 (in fact 6.22 or more, just Chinese language pack is too hard to find, so use 7.0, another 7.0 interface is also very good, XP style) // // file name: setup.rul // // description: installshield script // // Comments: this script was generated based on the selections you name in // the project wizard. Refer to the help topic Entitled "Modify // The Script That The Project Wizard Generate" for Information // on Possible Next Steps.//

// include header files #include "ifx.h" // string defines number xx1, xx2; installation declarations /////

// ----- DLL Function Prototype -----

// Your DLL Function Prototype

// ---- Script Function Prototype -----

// Your Script Function Prototypes Prototype CreateDatabase (String, String, String); // Additional Database Prototype Checkiis (); // Detection IIS Prototype Checkie (); // Detect IE version prototype checkmdac (); // Detection MDAC version prototype regcom (); // Register Jamil Component // Prototype Deliis (String); // Remove Virtual Directory Prototype Writeini (String, String, String); Prototype Deldatabase (String, String, String); // Your Global Variables

//// // 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, FeatureTransferData is called to perform file // transfer.// /// function OnFirstUIBefore () // number nResult, nSetupType; // string szTitle, szMsg; // string szLicenseFile, szQuestion; // string Szname, szcompany; // string sztargetpath; // string szdir; // string szfeatures, sztargetdir; // number NLEVEL; // list listStartcopy; // number nvsize; // number Nuser; // Number Nuse; number nResult, nSetupType; string szTitle, szMsg; string szLicenseFile, szQuestion; string szName, szCompany, szSerial; string szFeatures, szTargetdir; number nLevel; LIST listStartCopy, list; number nvSize; number nUser; number nOpt, svEdit1, svEdit2; STRING szServerIP , szServerPort, szServerIPDefault, szServerPortDefault; STRING szSQLsvr, szSQLusr, szSQLpwd, svSQLsvr, svSQLusr, svSQLpwd; STRING svName, svCompany, svSerial; STRING szFile, szTargetPath, szDir, szfolder; STRING szField1, szField2; STRING szDefault, svResult; string szComponents; OBJECT Piisobj; string sztitle1; string szmsg1, szmsg2; string szmsg11, szmsg12, szopt1, szopt2;

Bool bvopt1, bvopt2; begin // to do: if you want to enable background, window title, and caption bar title // settitle (@Product_Name, 24, White); // settitle (@Product_name, 0, BackgroundCaption); / / Enable (FULLWINDOWMODE); // Enable (BACKGROUND); // SetColor (BACKGROUND, RGB (0, 128, 128)); // SetFont (FONT_TITLE, STYLE_NORMAL, "Arial"); SHELL_OBJECT_FOLDER = @PRODUCT_NAME; nSetupType = TYPICAL SZDIR = INSTALLDIR; SZNAME = ""; szcompany = ""; DLG_Start: // Beginning 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_SDCUSTOMERINFORMATION: SZMSG = ""; sztitle = ""; NRESULT = SDCUSTomerInformation (sztitle, szname, szcompany, nuse); if (nresult = back) goto dlg_sdlicense;

Dlg_SdAskDestPath: szTitle = ""; szMsg = ""; nResult = SdAskDestPath (szTitle, szMsg, szDir, 0); INSTALLDIR = szDir; if (nResult = BACK) goto Dlg_SdCustomerInformation; Dlg_SelMode: // the database server dialog szTitle = " Whether to install the .NET framework "; szmsg =" Do not install the .NET framework, if the .NET framework is already installed. "; Szfield1 =" I want to install the .NET framework. "; SZFIELD2 =" I have installed it. , no need to install. "; svEdit1 = TRUE; svEdit2 = FALSE; setDialogTitle (DLG_ASK_TEXT, szTitle); // DialogSetInfo (DLG_INFO_CHECKSELECTION," ", 1); nOpt = EXCLUSIVE; nResult = AskOptions (nOpt, szMsg, szField1, svEdit1 , SZFIELD2, SVEDIT2; if (nresult = back) goto dlg_sdaskdestpath; if (svedit1 = true) Then if checkmdac () Then// If you have installed IF (LaunchappandWait (supportdir ^ "MDAC_TYP.EXE", ", Wait) <0) THEN MessageBox ("Installing Microsoft Data Access Components, please reinstall." <0) THEN MessageBox ("Annections when installing .NET framework, please reinstall.

", Severe); GTO DLG_SELMODE; ENDIF; Endif; 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 = INSTALLDIR; nvSize = 0; FeatureCompareSizeRequired (MEDIA, szTargetPath, nvSize); if (nvSize = 0!) then MessageBox (szSdStr_NotEnoughSpace, WARNING); goto Dlg_SetupType; endif; ENDIF; ENDIF;

Dlg_SdFeatureTree: if (! (NResult = BACK) && (nSetupType = CUSTOM)) goto Dlg_SetupType; szTitle = ""; szMsg = ""; szTargetdir = INSTALLDIR; szFeatures = ""; nLevel = 2; if (nSetupType = CUSTOM) then NResult = SDFEATURETREE (SZTITLE, SZMSG, SZTARGETDIR, SZFEATURES, NLEVEL); if (NResult = BACK) GOTO DLG_SETUPTYPE; ENDIF; DLG_ASKTEXT: // Set Database Server Dialog Sztitle = "Set IIS Information Service and Database Server"; SZMSG = " Now set the IIS system "; szquestion =" Please enter the host name or IP address of this server. The installer will set the IIS information service according to the information you provide. If you are not filled, the installer will automatically skip the site creation! " ; szServerIP = "address:"; szServerPort = "port:"; szServerIPDefault = "192.168.0.1"; szServerPortDefault = "80"; setDialogTitle (DLG_ASK_TEXT, szTitle); nResult = SdShowDlgEdit2 (szTitle, szQuestion, szServerIP, szServerPort, szServerIPDefault, SZSERVERPORTDEFAULT; if (nresult = back) goto DLG_SETUPTYPE; DLG_ASKSQL: // Setting the Database Server dialog SZTITLE = "Setting the database"; szmsg = "Now set the database system"; szquestion = "Please enter the username and password of the database server. The installer will create and optimize the database system according to the IP address you provide, and the following username and password.

If your username and password are wrong, the installer will automatically skip the settings of the data! "; // szsqlsvr =" host name: "; szsqlusr =" User Name: "; szsqlpwd =" Password: "; // svsqlsvr =" LocalHost "; svsqlusr =" sa "; svsqlpwd =" "; setDialogtitle (DLG_ASK_Text, szTitle); nResult = SdShowDlgEdit2 (szTitle, szQuestion, szSQLusr, szSQLpwd, svSQLusr, svSQLpwd); if (nResult = BACK) goto Dlg_AskText; Dlg_SdStartCopy: szTitle = ""; szMsg = ""; szTitle1 = "installation failed"; szMsg11 = "Since the installation causes unexpectedly, the installation failed"; SZMSG12 = "Click to complete the exit installation. "; SzOpt1 =" "; szOpt2 =" "; listStartCopy = ListCreate (STRINGLIST); ListAddString (listStartCopy," User Name: " szName, AFTER); ListAddString (listStartCopy," the company name: " szCompany, AFTER); ListAddString (listStartCopy, "target directory:" szDir, AFTER); if (svEdit1 = TRUE) thenListAddString (listStartCopy, "IP address:" szServerIPDefault, AFTER); ListAddString (listStartCopy, "port number:" szServerPortDefault, AFTER); Endif; ListAddString (ListStartCopy, please confirm the information you fill in, press the copy file ", after); // listStartCopy = listcreate (StringList); // the folload is an example of how to add a string (szname) to a list (listStartCopy) // eg ListAddString (listStartCopy, szName, AFTER);.. nResult = SdStartCopy (szTitle, szMsg, listStartCopy); ListDestroy (listStartCopy); if (nResult = BACK) goto Dlg_SdFeatureTree;

Enable (statusex); if CHECKIIS () THEN if (xx1 = 2) goto dlg_asktext; // Judgment the site establishes success // regcom (); // Register Component CreateDatabase (SVSQLPWD); // Create and optimize Database Writeini (SZSERVERIPDEFAULT, SVSQLUSR, SVSQLPWD); // Write IIS Else MessageBox ("Your computer is not installed IIS! Please try again!", Severe); Endif; Return 0; end; ///// / FUNCTION: OnMaintUIBefore //// EVENT: MaintUIBefore event is sent when end user runs installation that // has already been installed on the machine usually this happens // through Add / Remove Programs applet In the handler, installation // usually.. . displays UI allowing end user to modify existing installation // or uninstall application After this function returns, // FeatureTransferData is called to perform file transfer./////function OnMaintUIBefore () NUMBER nResult, nType; STRING szTitle, szMsg, svDir , SvResult, Szcaption; String Svip, Svuser, Svpass; Begin // To do: i F You Want To Enable Background, Window Title, And Caption Bar Title // Settitle (@Product_name, 24, White); // settitle (@Product_name, 0, BackgroundCaption); // setColor (Background, RGB (0, 128, 128)); // enable (FullwindowMode); // enable (Background); DLG_Start: disable (backbutton); NTYPE = SDWELCOMEMAINT (SZTITLE, SZMSG, MODIFY); Enable (Backbutton);

if (nType = REMOVEALL) then svResult = SdLoadString (IFX_MAINTUI_MSG); szCaption = SdLoadString (IFX_ONMAINTUI_CAPTION); nResult = SprintfBox (MB_OKCANCEL, szCaption, "% s", svResult); if (nResult = IDCANCEL) goto Dlg_Start; endif;

nResult = NEXT; Dlg_SdFeatureTree: if (nType = MODIFY) then szTitle = ""; szMsg = ""; nResult = SdFeatureTree (szTitle, szMsg, INSTALLDIR, "", 2); if (nResult = BACK) goto Dlg_Start; endif;

switch (nType) case REMOVEALL: FeatureRemoveAll (); case REPAIR: FeatureReinstall (); endswitch; GetProfString (SystemFolder ^ "dbconn.ini", "dbconnection", "ip", svip); GetProfString (SystemFolder ^ "dbconn.ini" , "dbconnection", "db_user", svuser; getprofstring (systemfolder ^ "dbconn.ini", "dbconnection", "db_pars", svpass); // svall = svip "," svuser "," SVPASS; / / SDSHOWMSG (SVALL, WAIT); // DELAY (5); Deldatabase (SVIP, SVUSER, SVPASS); deletefile (installdir ^ "Database // kill.out"); enable (statusex);

//// create and optimize database // function CreateDataBase (svSQLsvr, svSQLusr, svSQLpwd) STRING szCmdLine1, szWaitTxt, szdatabase, szdatabase1, path, path1, path3; begin path = INSTALLDIR ^ "database // fenoffice.mdf"; path3 = InstallDir ^ "Database // Fenoffice_log.ldf"; szwaittxt = "Creating a database ...."; sdshowmsg (szwaittxt, true); delay (2); //copyfile (Supportdir^"kill.sql",installdir^ " database // kill.sql "); CopyFile (SUPPORTDIR ^" fenoffice.mdf ", INSTALLDIR ^" database // fenoffice.mdf "); CopyFile (SUPPORTDIR ^" fenoffice_log.ldf ", INSTALLDIR ^" database // fenoffice_log.ldf "); // szcmdline =" hello "; szdatabase =" / u " svsqlusr " / p " svsqlpwd " / s " svsqlsvr " / q / "exec sp_attach_db n'fenoffice ', n'" PATH " , N '" Path3 "' / ""; // szdatabase, wait); // delay (3); if (Launchappandwait ("OSQL.exe", SZDatabase, Wait <0) Then; MessageBox (" Database creation failed! Please confirm that Microsoft SQL Server 2000./n is still unable to resolve, please contact system supplier! ", Severe); Endif; Path1 = installdir ^" Database "; // szdatabase1 =" -S " SVSQLUSR " -u " svsqlusr " -p " svsqlpwd " -d master -n -i " Path1 " // kill.sql -o " P Ath1 "// kill.out"; // szdshowmsg (szdatabase2, wait); // delay (3); if (Launchappandwait ("OSQL.exe", SZDatabase1, Wait) <0) ThenMessageBox ("Configuring Database Failed! Please try manual configuration! ", Severe); endif; szwaittxt, false; return 0;

// // // detect whether the installation iis // // function CheckIIS () NUMBER nvType, nvSize; STRING svvalue; begin RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if (RegDBKeyExist ( "System // CurrentControlSet // Services // IISADMIN") = 1) THEN RETURN (1); Else Return (0); Endif; End; // // Detect IE version // Function Checkie () Number NVTYPE, NVSIZE; STRING SVVALUE, SZKEY, SZNAME; Begin szKey = "SOFTWARE // Microsoft // Internet Explorer"; szName = "version"; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); RegDBGetKeyValueEx (szKey, szName, nvType, svvalue, nvSize); if (svvalue = "6.0.2600.0000") then return ( 0); Else Return (1); Endif; end;

// // detect mdac version of // // function Checkmdac () NUMBER nvType, nvSize; STRING svvalue, szKey, szName; begin szKey = "SOFTWARE // Microsoft // DataAccess"; szName = "version"; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE RegdbgetKeyValueex (Szkey, SZNAME, NVTYPE, SVVALUE, NVSIZE); IF (SvValue = "2.71.9030.9)") The return (0); Else Return (1); ENDIF; END;

///// Write dbconn.ini file /// Function Writeini (SVSQLSVR, SVSQLUSR, SVSQLPWD) String Svdate, InIfile, Svresult, Szinfo, Szwaittxt; Number NVResult; Begin // Szwaittxt = "is configuring system files, please Slightly ... "

InIfile = supportdir ^ "dbconn.ini"; // szwaittxt, true); // delay (2); IF (getSystemInfo (Date, NVResult, SvResult) <0) THEN

Szinfo = "You cannot get system time";

Else Svdate = SvResult "" "; Endif; IF (getsysteminfo (Time, NVResult, SvResult) <0) THEN

Szinfo = "You cannot get system time";

Else Svdate = SVDATE SVRESULT; ENDIF;

IF (WriteProfString (INIFILE, SVSQLSVR) <0) Then MessageBox ("DBCONN.INI error, system will not run!", severe); endif; if (WriteProfstring (INIFILE, "DBConnection", "IP", SVSQLSVR) <0) Then MessageBox ("DBCONN.INI error, system will not run!" MessageBox ("Dbconn.ini error, system will not run!", Severe); Endif; IF (WriteProfstring (INIFILE, "DBCONNECTION", "DB_Pass", SVSQLPWD) <0) Then MessageBox ("DBCONN.INI error, system Unable to run! ", Seve); Endif; IF (WriteProfstring (INIFILE," DBCONNECTION "," Database "," FenOffice ") <0) The MessageBox (" Dbconn.ini error, the system will not run! ", Severe); Endif; IF (INIFILSTRING (INIFILE, "WebWork", "WebWorkstart", "DBCONN.INI error, system will not run!", severe); Endif; IF (WriteProfstring (INIFILE, "Webwork "WebworkPath", InstallDir <0) The MessageBox ("dbconn.ini error, the system will not run!", seve); Endif; CopyFile (supportdir ^ "dbconn.ini", systemfolder ^ "dbconn.ini") End; // // Register component // function regcom () string szline, szwaittxt; beginszline = systemfolder ^ "jmail.dll"; szwaittxt = "Register components ..."; sdshowmsg (szwaittxt, true); delay; (2); CopyFile (supportdir ^ "jmail.dll", systemfolder ^ "jmail.dll"); if (Launchappandwait ("Regsvr32.exe", Szline, Wait) <0) The MessageBox ("Registration component failed, please try Manual registration " SZLINE, SEVERE);

// Else // MessageBox ("Successful registration component!" szline, information); // szline, true); // delay (3); endif; end; // function deliis (virtualfolder) // String szcmdline ; // begin // Remove the existing virtual directory // szcmdline = supportdir ^ "Adsutil.vbs Delete W3SVC / 1 / root /" ^ VirtualFolder; // IF (Launchappandwait ("Cscript.exe", Szcmdline, Wait < 0) THEN // MessageBox ("Setting IIS information service failed, try manual configuration!", Information; // endif; // end;

/// ////// Function Deldatabase (Server, User, Pass) String Szwaittxt, Szdatabase1, Szdatabase2, Szdatabase3, Path1; Begin

Szwaittxt = "I am deleting database ...."; szdatabase2 = "/ u" user "/ p" pass "/ q /" exec killspid n'fenoffice '"; launchappandwait (" osql.exe ", szdatabase2, wait ); // szDatabase2, wait); // delay (3); szdatabase3 = "/ u" user "/ p" pass "/ q /" exec sp_dbremove n'fenoffice '"; launchappandwait (" OSQL. Exe ", szdatabase3, wait); // szdshowmsg (szdatabase3, wait); // delay (3); sdshowmsg (szwaittxt, false); return 0;

转载请注明原文地址:https://www.9cbs.com/read-112209.html

New Post(0)