Use InstallShield to package ASP scripts

Source: Internet
Author: User

# Include "ifx. h" // cannot be moved
//////////////////////////////////////// //////////////////////////////////////
// Use InstallShield to pack and automatically install ASP Software
// Original Author: Jaron)
// URL: http://www.jiangdu.net
// Mail: jaron@jdinfo.net
// Posted on Netease, ChinaASP, and ASPHouse for the first time
//////////////////////////////////////// //////////////////////////////////////
// Function:
// 1. copy the file
// 2. Optional. Automatic Setting of independent site running (set IIS)
// 3. Optional. automatically set the virtual site to run (set IIS)
// 4. Set the directory to readable, writable, and runable scripts
// 5. automatically create ODBC
// 6. automatically create or append an MDF-format SQL database and optimize it
// 7. automatically install the ScriptEncode Decoder
// This article only lists the Script part of InstallShield, and contains two VBS files and other settings.
// If you have any questions during the test, please come to the http://www.jiangdu.net/bbs programming space edition for discussion
//////////////////////////////////////// //////////////////////////////////////
Prototype CreateDataBase (STRING, STRING, STRING );
Prototype CreateWebSite (STRING, STRING); // create an IIS Site
Prototype CreateVirtualDir (STRING); // create a virtual directory

//////////////////////////////////////// //////////////////////////////////////
//
// 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, nOpt, svEdit1, svEdit2;
STRING szTitle, szMsg, szbmp path;
STRING szLicenseFile, szQuestion;
STRING szServerIP, szServerPort, szServerIPDefault, szServerPortDefault;
STRING szSQLsvr, szSQLusr, szSQLpwd, svSQLsvr, svSQLusr, svSQLpwd;
STRING svName, svCompany, svSerial;
STRING szFile, szTargetPath, szDir, szfolder;
STRING szComponents, szTargetdir;
STRING szField1, szField2;
STRING szDefault, svResult;
OBJECT piisObj;
LIST list, listStartCopy;
NUMBER nLevel, nvSize;
Begin

Szbmp Path = "C:" ^ "temp" ^ "left.bmp ";
DialogSetInfo (DLG_INFO_ALTIMAGE, szbmp path, TRUE); // you can specify the image on the left.
// To Do: 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 ));

// Set the default value
TARGETDIR = "C:" ^ "inetpub" ^ "JaronSoft" ^ @ FOLDER_NAME;
SzDir = TARGETDIR;
SHELL_OBJECT_FOLDER = @ FOLDER_NAME;
SvName = "trial user ";
SvCompany = "JDinfo Network ";
SvSerial = "111-1111111 ";

Dlg_Start:
// Beginning of dialogs label

Dlg_SdWelcome: // welcome dialog box
SzTitle = "Welcome ";
SzMsg = "";
NResult = SdWelcome (szTitle, szMsg );
If (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense: // software license agreement dialog box
SzLicenseFile = SUPPORTDIR ^ "license.txt ";
SzTitle = "License Agreement ";
SzMsg = "";
SzQuestion = "";
NResult = SdLicense (szTitle, szMsg, szQuestion, szLicenseFile );
If (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SdShowInfoList: // readme file dialog box
SzFile = SUPPORTDIR ^ "infolist.txt ";
List = ListCreate (STRINGLIST );
ListReadFromFile (list, szFile );
SzTitle = "README ";
SzMsg = "";
NResult = SdShowInfoList (szTitle, szMsg, list );
ListDestroy (list );
If (nResult = BACK) goto Dlg_SdLicense;

Dlg_SdRegisterUserEx: // user information dialog box
SzMsg = "";
SzTitle = "User Information ";
NResult = SdRegisterUserEx (szTitle, szMsg, svName, svCompany, svSerial );
If (nResult = BACK) goto Dlg_SdShowInfoList;
// Check the serial number
// If (CHK_serial (svCompany, svSerial) <0) then
// Goto Dlg_SdRegisterUserEx;
// Endif;
// Check the serial number
Dlg_SdAskDestPath: // installation location dialog box
SzTitle = "check the serial number ";
SzMsg = "";
NResult = SdAskDestPath (szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
If (nResult = BACK) goto Dlg_SdRegisterUserEx;

Dlg_SetupType: // installation type dialog box
NSetupType = TYPICAL;
SzTitle = "installation type ";
SzMsg = "select the method for installation ";
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: // dialog box
If (nResult = BACK) & (nSetupType! = CUSTOM) goto Dlg_SetupType;
SzTitle = "dialog box ";
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_SdSelectFolder: // dialog box
Szfolder = SHELL_OBJECT_FOLDER;
SzTitle = "folder ";
SzMsg = "";
NResult = SdSelectFolder (szTitle, szMsg, szfolder );
SHELL_OBJECT_FOLDER = szfolder;
If (nResult = BACK) goto Dlg_SdComponentTree;

Dlg_SelMode: // set database server dialog box
SzTitle = "set" + @ PRODUCT_NAME + "running mode ";
SzMsg = "select the method for running the software. We strongly recommend that you run the software on an independent site ";
SzField1 = "independent site running (automatic creation of new sites )";
SzField2 = "run in virtual directory mode (automatically create virtual directory )";
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_SdSelectFolder;
If (svEdit1 = FALSE) goto Dlg_SdStartCopy;

Dlg_AskText: // set database server dialog box
SzTitle = "setting IIS Information Service and database server ";
SzMsg = "starting to set up IIS system now ";
SzQuestion = "enter the host name or IP address of the server. The installer sets the IIS information service according to the information you provide. If you do not enter this information, the installer will automatically skip 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_SelMode;

Dlg_AskSQL: // set database server dialog box
SzTitle = "set Database ";
SzMsg = "start setting up the Microsoft SQL Server database system now ";
SzQuestion = "Enter the username and password of the SQL SERVER database SERVER. The installer will create and optimize the database system according to the IP address provided in the previous step and the following username and password. If the user name and password you provided are incorrect, the installer will automatically skip the data settings! ";
SzSQLsvr = "Host Name :";
SzSQLusr = "User name :";
SzSQLpwd = "Password :";
SvSQLsvr = "localhost ";
SvSQLusr = "sa ";
SzSQLpwd = "";
SetDialogTitle (DLG_ASK_TEXT, szTitle );
NResult = SdShowDlgEdit3 (szTitle, szQuestion, szSQLsvr, szSQLusr, szSQLpwd, svSQLsvr, svSQLusr, svSQLpwd );
If (nResult = BACK) goto Dlg_SelMode;

Dlg_SdStartCopy: // file copy start dialog box
SzTitle = "Start copying files ";
SzMsg = "click Next To Start copying files ";
ListStartCopy = ListCreate (STRINGLIST );
ListAddString (listStartCopy, "User name:" + svName, AFTER );
ListAddString (listStartCopy, "company name:" + svCompany, AFTER );
ListAddString (listStartCopy, "serial number:" + svSerial, AFTER );
ListAddString (listStartCopy, "target directory:" + szDir, AFTER );
If (svEdit1 = TRUE) then
ListAddString (listStartCopy, "IP Address:" + szServerIPDefault, AFTER );
ListAddString (listStartCopy, "port:" + szServerPortDefault, AFTER );
Endif;
ListAddString (listStartCopy, "confirm the information you entered and Start copying the file by following the next step", AFTER );
NResult = SdStartCopy (szTitle, szMsg, listStartCopy );
ListDestroy (listStartCopy );
If (nResult = BACK) goto Dlg_AskText;
// Setup default status
SetStatusWindow (0 ,"");
Enable (STATUSEX );
StatusUpdate (ON, 100 );
If (svEdit1 = TRUE) then
CreateWebSite (szServerIPDefault, szServerPortDefault); // start to create an IIS Site
Endif;
If (svEdit2 = TRUE) then
CreateVirtualDir ("NetOA"); // start to create an IIS Site
Endif;
CreateDataBase (svSQLsvr, svSQLusr, svSQLpwd); // create and optimize a database

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, szMsg1, szMsg2, szOption1, szOption2, szjavasline;
NUMBER bOpt1, bOpt2;

Begin
// Set_vod_liveaddress ();

SzCmdLine = suppdir dir ^ "SCE10CHS. EXE ";
If (LaunchAppAndWait (szCmdLine, "/q", WAIT) <0) then
MessageBox ("decoding program cannot be installed. Please contact the supplier.", SEVERE );
Endif;

Disable (STATUSEX );
BOpt1 = FALSE;
BOpt2 = FALSE;
SzMsg1 = SdLoadString (IFX_SDFINISH_MSG1 );
SzMsg2 = "Please browse the WEB server of this host" + @ PRODUCT_NAME + "virtual directory example: http: // Localhost /";
SzOption1 = "";
SzOption2 = "";
SzTitle = @ PRODUCT_NAME + "installation completed ";
SdFinishEx (szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2 );

SzCmdLine = "http: // LocalHost ";
// If (LaunchApp (PROGRAMFILES ^ "Internet Explorer" ^ "IEXPLORE. EXE", szCmdLine) <0) then
// MessageBox ("cannot open the browser.", SEVERE );
// Endif;

Return 0;
End;

//////////////////////////
// Create an IIS Site
//////////////////////////
Function CreateWebSite (szServerIPDefault, szServerPortDefault)
STRING szwaitline, szWaitTxt;
Begin
If (szServerIPDefault = "") | (szServerPortDefault = "") then
MessageBox ("You have not set" + @ PRODUCT_NAME + "Running Server IP address or port !! An error occurred while setting IIS Information Service! Create an IIS Site and set the main directory to "+ TARGETDIR, SEVERE );
Else
SzWaitTxt = "creating IIS and setting site ....";
SdShowMsg (szWaitTxt, TRUE );
Delay (2 );
SzCmdLine = suppdir dir ^ "mkw3site. vbs" + "-r" + TARGETDIR + "-I" + szServerIPDefault + "-o" + szServerPortDefault + "-t" + @ PRODUCT_NAME;
If (LaunchAppAndWait ("WScript.exe", szCmdLine, WAIT) <0) then
MessageBox ("the WEB virtual directory cannot be created, WScript.exe is not found, or the execution script is incorrect.", SEVERE );
Endif;
SdShowMsg (szWaitTxt, FALSE );
Endif;
Return 0;
End;

//////////////////////////
// Create a virtual directory
//////////////////////////
Function CreateVirtualDir (VirtualFolder)
STRING szwaitline, szWaitTxt;
Begin
If (VirtualFolder = "") then
MessageBox ("the name of the virtual directory cannot be read! Contact the system supplier! "+ TARGETDIR, SEVERE );
Else
SzWaitTxt = "Creating" + @ PRODUCT_NAME + "virtual directory ....";
SdShowMsg (szWaitTxt, TRUE );
Delay (2 );
SzCmdLine = SUPPORTDIR ^ "mkwebdir. vbs" + "-w 1-v \" "+ VirtualFolder +" \ ", \" "+ TARGETDIR + "\"";
If (LaunchAppAndWait ("WScript.exe", szCmdLine, WAIT) <0) then
MessageBox ("the WEB virtual directory cannot be created, WScript.exe is not found, or the execution script is incorrect.", SEVERE );
Endif;
SdShowMsg (szWaitTxt, FALSE );
Endif;
Return 0;
End;

//////////////////////////
// Create and optimize a database
//////////////////////////
Function CreateDataBase (svSQLsvr, svSQLusr, svSQLpwd)
STRING szwaitline, szWaitTxt;
Begin
SzWaitTxt = "Creating" + @ PRODUCT_NAME + "required database ....";
SdShowMsg (szWaitTxt, TRUE );
Delay (2 );
SzCmdLine = "/U" + svSQLusr + "/P" + svSQLpwd + "/S" + svSQLsvr + "/Q \" exec sp_attach_db N 'oss stem ', n' "+ SUPPORTDIR ^" OASystem_data.mdf '\"";
If (LaunchAppAndWait ("osql.exe", szCmdLine, WAIT) <0) then
MessageBox ("database creation failed! Check that Microsoft SQL Server 2000 is installed in your system. If the problem persists, contact the system supplier! ", SEVERE );
Endif;
SdShowMsg (szWaitTxt, FALSE );
SzWaitTxt = "being optimized" + @ PRODUCT_NAME + "System database ....";
SdShowMsg (szWaitTxt, TRUE );
Delay (2 );
SzCmdLine = "/U" + svSQLusr + "/P" + svSQLpwd + "/S" + svSQLsvr + "/Q \" use OASystem; exec sp_updatestats \"";
If (LaunchAppAndWait ("osql.exe", szCmdLine, WAIT) <0) then
MessageBox ("database optimization failed! You can execute use OASystem; exec sp_updatestats in the SQL query analyzer! ", SEVERE );
Endif;
SdShowMsg (szWaitTxt, FALSE );
Return 0;
End;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.