Methods for packaging and automatic installation of ASP software with IS6-application techniques

Source: Internet
Author: User
Tags file copy goto microsoft sql server
#include "ifx.h"//cannot be moved
//////////////////////////////////////////////////////////////////////////////
Packaging and automatic installation of ASP software with InstallShield
Original Author: Jia Jun (Jaron)
Website: http://www.jiangdu.net;
Mail: jaron@jdinfo.net
First published in NetEase, Chinaasp,asphouse
//////////////////////////////////////////////////////////////////////////////
Function:
1. File copy
2. Optional automatic set up Independent site run (set up IIS)
3. Optional Automatic Setup virtual site run (set up IIS)
4. Set directory readable, writable and run scripts
5. Automatically create ODBC
6. Automatically create or attach an MDF-formatted SQL database and optimize
7. Automatically install Scriptencode decoder program
This article lists only the Script parts of InstallShield, as well as two VBS files and other settings
Any questions during the test, please come to Http://www.jiangdu.net/bbs; Programming Space Edition 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 was run for the
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,szbmppath;
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

Szbmppath= "C:" ^ "temp" ^ "left.bmp";
Dialogsetinfo (Dlg_info_altimage, Szbmppath, TRUE); Set the picture on the left
To do:if your want to enable background, window title, and caption bar title
Settitle (@TITLE_MAIN, white);
Settitle (@TITLE_CAPTIONBAR, 0, backgroundcaption);
Enable (Fullwindowmode);
Enable (BACKGROUND);
SetColor (Background,rgb (0, 128, 128));

Default Value setting
TARGETDIR = "C:" ^ "inetpub" ^ "Jaronsoft" ^ @FOLDER_NAME;
Szdir = TARGETDIR;
Shell_object_folder = @FOLDER_NAME;
svname = "Beta user";
Svcompany = "Jdinfo network";
svserial = "111-1111111";

Dlg_start:
Beginning of Dialogs label

Dlg_sdwelcome://Welcome dialog box
SzTitle = "Welcome to enter";
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 serial number
if (Chk_serial (Svcompany, svserial) <0) Then
Goto Dlg_sdregisteruserex;
endif
Check Serial number complete
DLG_SDASKDESTPATH://Installation Location dialog box
SzTitle = "Check 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 = "Please choose which way you need to install";
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 + "" mode of operation;
szmsg = "Please choose the way software runs, strongly recommend the use of stand-alone site mode";
szfield1= "Standalone site mode (automatically create a new site)";
szfield2= "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 = "Set up IIS Information Service and database server";
szmsg = "Start setting up IIS system Now";
szquestion= "Please enter the host name or IP address of this server, and setup will set up the IIS information service according to the information you provided." If you do not fill out, the installer will automatically skip the creation of the site! ";
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 Microsoft SQL Server database system now";
szquestion= "Please enter a username and password for the SQL Server database server, and setup will create and optimize the database system according to the IP address and the following username and password that you provided in the previous step." If you provide a wrong username and password, Setup will automatically skip the settings for the data! ";
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://Start Copying Files dialog box
SzTitle = "Start copying files";
szmsg = "Click Next to start copying files";
Liststartcopy = Listcreate (stringlist);
Listaddstring (Liststartcopy, "username:" +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 slogan:" +szserverportdefault,after);
endif
Listaddstring (liststartcopy, "Please make sure you fill in the information, press next to start copying files", 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 creating an IIS site
endif
if (svedit2=true) then
Createvirtualdir ("Netoa"); Start creating an IIS site
endif
CreateDatabase (SVSQLSVR,SVSQLUSR,SVSQLPWD); Creating and Optimizing Databases

return 0;
End
//////////////////////////////////////////////////////////////////////////////
//
Function: Onfirstuiafter
//
Event: Firstuiafter event is sent after file transfer, when installation
is run for the "the" "the" given machine. In this event handler
Installation usually displays UI that would inform end user
Installation has been completed successfully.
//
///////////////////////////////////////////////////////////////////////////////
function Onfirstuiafter ()
STRING SZTITLE,SZMSG1, SZMSG2, SzOption1, Szoption2,szcmdline;
Number BOPT1, BOpt2;

Begin
Set_vod_liveaddress ();

szCmdLine = supportdir ^ "Sce10chs. EXE ";
if (launchappandwait (szCmdLine, "/q", wait) < 0) Then
MessageBox ("You cannot install the decoder, please contact the vendor.", SEVERE);
endif

Disable (Statusex);
BOPT1 = FALSE;
BOpt2 = FALSE;
SZMSG1 = sdloadstring (IFX_SDFINISH_MSG1);
SZMSG2 = "Please browse the" + @PRODUCT_NAME + "virtual directory on this host Web server: \ n http://Localhost/";;
SzOption1 = "";
SzOption2 = "";
SzTitle = @PRODUCT_NAME + "Installation Complete";
Sdfinishex (SZTITLE,SZMSG1,SZMSG2,SZOPTION1,SZOPTION2,BOPT1,BOPT2);

szCmdLine = "Http://LocalHost";;
if (Launchapp (programfiles ^ "Internet Explorer ^" IEXPLORE.) EXE ", szCmdLine) < 0) Then
MessageBox ("Cannot open browser.", SEVERE);
endif

return 0;
End


//////////////////////////
Create an IIS site
//////////////////////////
function Createwebsite (Szserveripdefault,szserverportdefault)
STRING Szcmdline,szwaittxt;
Begin
if ((Szserveripdefault = "") | | (Szserverportdefault = "")) Then
MessageBox ("You did not set" + @PRODUCT_NAME + "Running the server IP address or port!! IIS Information Service settings failed! \ nplease create your own IIS site and set the home directory to: "+targetdir,severe";
Else
Szwaittxt= "is creating IIS and setting up sites ...";
Sdshowmsg (Szwaittxt, TRUE);
Delay (2);
szCmdLine = supportdir ^ "Mkw3site.vbs" + "-r" +targetdir+ "-i" +szserveripdefault+ "-o" +szserverportdefault+ "T" + @PRODU Ct_name;
if (launchappandwait ("WScript.exe", szcmdline,wait) < 0) Then
MessageBox ("Cannot establish a Web virtual directory, cannot find WScript.exe or execute a script error.", SEVERE);
endif
Sdshowmsg (Szwaittxt, FALSE);
endif
return 0;
End

//////////////////////////
Create a virtual directory
//////////////////////////
function Createvirtualdir (VirtualFolder)
STRING Szcmdline,szwaittxt;
Begin
if (VirtualFolder = "") Then
MessageBox ("Failed to read the name of the virtual directory!") Contact your system Provider! "+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 ("Cannot establish a Web virtual directory, cannot find WScript.exe or execute a script error.", SEVERE);
endif
Sdshowmsg (Szwaittxt, FALSE);
endif
return 0;
End

//////////////////////////
Creating and Optimizing Databases
//////////////////////////
function CreateDatabase (SVSQLSVR,SVSQLUSR,SVSQLPWD)
STRING Szcmdline,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 ' oasystem ', n ' "+supportdir ^" Oasyste M_data.mdf ' "";
if (launchappandwait ("Osql.exe", szcmdline,wait) < 0) Then
MessageBox ("Database creation failed!") Please confirm that you have installed Microsoft SQL Server 2000.\n on your system if it is still unresolved, please contact your system vendor! ", SEVERE);
endif
Sdshowmsg (Szwaittxt, FALSE);
Szwaittxt= "is optimizing + @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 \ n use oasystem in SQL Query Analyzer; exec sp_updatestats \ n Complete! ", 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.