Use installshield9 for ASP software packaging and automatic Database Installation

Source: Internet
Author: User

CopyCode The Code is as follows: # define bitmap_id 1

# Include "ifx. H" // cannot be moved

Prototype createwebsite (string, string); // create an IIS Site
Prototype createvirtualdir (string); // create a virtual directory
Prototype createdatabase (string, String, string); // create a SQL database
Prototype checkiis (); // example: Check whether IIS is installed.

String tmp_product_name, tmp_product_version, tmp_company_name, tmp_product_key, tmp_title_captionbar;
String globalstr, destdir, destsvr, destsa, destpw;
Number nvfilehandle, nvfilehandlebak, asaline;
Bool iscreatedb;
String nsetuptype, szsqlsvr, szsqlusr, szsqlpwd, szsqlsvrdefault, szsqlusrdefault, szsqlpwddefault;
String szadsvr, szadusr, szadpwd, szadsvrdefault, szadusrdefault, szadpwddefault;
String szaddomain, szadou, szaddomaindefault, szadoudefault, addc1;
String svname, svcompany, svserial;

Function onfirstuibefore ()

Number nresult, nopt, svedit1, svedit2;
String sztitle, szmsg, szbmp path;
String szlicensefile, szquestion;
String szserverip, szserverport, szserveripdefault, szserverportdefault;

String szfile, sztargetpath, szdir, szfolder;
String szcomponents, sztargetdir;
String szfield1, szfield2;
String szdefault, svresult;
Object piisobj;
List list, liststartcopy;
Number nlevel, nvsize;

Begin

Tmp_product_name = "XXX e-government platform ";
Tmp_product_version = "V2.0 ";
Tmp_company_name = "XXX company ";
Tmp_product_key = "88888888 ";
Tmp_title_captionbar = "0 ";

Szbmp Path = supportdir ^ "left.bmp ";
Dialogsetinfo (dlg_info_altimage, szbmp path, false); // 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 ));
Placebitmap (szbmp path, bitmap_id, 0, 0, fullscreen );

// Set the default value
Targetdir = "C:" ^ "inetpub" ^ @ folder_name;
Szdir = targetdir;
Shell_object_folder = @ folder_name;
Svname = "";
Svcompany = "";
Svserial = "88888888 ";

If (checkiis () = 1) Then // example: Check whether IIS is installed.
// MessageBox ("IIS has been installed, and installation continues! ", Severe );
Goto dlg_start;
Else
MessageBox ("IIS is not installed in this system. Please install IIS first! ", Warning );
Goto end_all_install; // end the installation.
Endif;

Dlg_start: // start dialog box

Dlg_sdwelcome: // welcome dialog box
Sztitle = "Welcome to install and use" + tmp_product_name + "" + tmp_product_version;
Szmsg = "";
Nresult = sdwelcome (sztitle, szmsg );
If (nresult = back) goto dlg_start;

Dlg_sdlicense: // software license agreement dialog box
Szlicensefile = supportdir ^ "license.txt ";
Sztitle = "End User 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 = "system information overview ";
Szmsg = "System Overview ";
Nresult = sdshowinfolist (sztitle, szmsg, list );
Listdestroy (list );
If (nresult = back) goto dlg_sdlicense;

Dlg_sdregisteruserex: // user information dialog box
Szmsg = "";
Sztitle = "User Information Registration ";
Svcompany = "XXX Province ";
Svserial = "XXX unit ";
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_inputadadmin: // set the IP address and User Name of the Active Directory Server.

Sztitle = "Set Directory (AD) server ";
Szmsg = "set the IP address, Administrator account, and password of the directory (AD) server now ";
Szquestion = "Enter the Administrator account and password of the directory (AD) server to installProgramYou will be configured according to the IP address, account, and password you provide. If the account or password you provided is incorrect, the system will not work properly! ";
Szadsvr = "IP Address :";
Szadusr = "Account Number :";
Szadpwd = "Password :";
Szadsvrdefault = "192.168.8.8 ";
Szadusrdefault = "Administrator ";
Szadpwddefault = "";
Setdialogtitle (dlg_ask_text, sztitle );
Nresult = sdshowdlgedit3 (sztitle, szquestion, szadsvr, szadusr, szadpwd, szadsvrdefault, szadusrdefault, szadpwddefault );
If (nresult = back) goto dlg_sdregisteruserex;

Dlg_inputaddomain: // set the domain and organization of the Active Directory Server

Sztitle = "Set Directory (AD) server ";
Szmsg = "now start to set the domain name and organizational unit of the directory (AD) server ";
Szquestion = "Enter the complete domain name and organizational unit of the directory (AD) server. The installer will configure according to the information you provide. If the information you provided is incorrect, the system will not work properly! ";
Szaddomain = "complete domain name :";
Szadou = "organizational unit :";

Szaddomaindefault = "xx.xx.com ";
Szadoudefault = "XXX domain name ";

Setdialogtitle (dlg_ask_text, sztitle );
Nresult = sdshowdlgedit2 (sztitle, szquestion, szaddomain, szadou, szaddomaindefault, szadoudefault );
// Convert the domain name to three DC
If (strsub (addc1, szaddomain, 0, strfindex (szaddomain, ".", 0) + 1) <0) then
// Only take the first one, and the following is fixed
MessageBox ("the domain name you entered is incorrect. Please enter it again! ", Warning );
Goto dlg_inputaddomain;
Endif;
If (nresult = back) goto dlg_sdregisteruserex;

Dlg_setuptype: // installation type dialog box
Nsetuptype = "full installation ";
Sztitle = "installation type ";
Szmsg = "select the method for installation ";
Nresult = sdsetuptypeex (sztitle, szmsg, "", nsetuptype, 0 );
If (nresult = back) then
Goto dlg_sdregisteruserex;
Endif;

If (nsetuptype = "main program only") then
Goto dlg_sdaskdestpath;
Endif;

dlg_asksql: // set database server dialog box
sztitle = "set SQL database";
szmsg = "set 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 you provided and the user name and password below. If the user name and password you provided are incorrect, the installer will automatically skip the data settings! ";
szsqlsvr =" Host Name: ";
szsqlusr =" username: ";
szsqlpwd =" Password :";
szsqlsvrdefault = "192.168.8.8";
szsqlusrdefault = "sa";
szsqlpwddefault = "";
setdialogtitle (dlg_ask_text, sztitle );
nresult = reverse (sztitle, szquestion, szsqlsvr, szsqlusr, szsqlpwd, szsqlsvrdefault, szsqlusrdefault, szsqlpwddefault);
If (nresult = back) goto reverse;

Dlg_sdstartcopy: // file copy start dialog box
Sztitle = "Confirm database information ";
Szmsg = "click Next to continue ";
Liststartcopy = listcreate (stringlist );
Listaddstring (liststartcopy, "User name:" + svname, after );
Listaddstring (liststartcopy, "company name:" + svcompany, after );
Listaddstring (liststartcopy, "Host Name:" + szsqlsvrdefault, after );
Listaddstring (liststartcopy, "User name:" + szsqlusrdefault, after );
Listaddstring (liststartcopy, "Password:" + szsqlpwddefault, after );
Listaddstring (liststartcopy, "", after );
Listaddstring (liststartcopy, "confirm the information you entered and continue with", after );

Iscreatedb = true; // The database installation flag is true.
Destsvr = szsqlsvrdefault;
Destsa = szsqlusrdefault;
Destpw = szsqlpwddefault;
Nresult = sdstartcopy (sztitle, szmsg, liststartcopy );

Listdestroy (liststartcopy );
If (nresult = back) goto dlg_asksql;
Setstatuswindow (0 ,"");
Enable (statusex );
Statusupdate (on, 100 );

If (nsetuptype = "database only") then
Goto end_all_install;
Endif;

// Start the main program installation
Dlg_sdaskdestpath: // installation location dialog box
Sztitle = "main program installation location ";
Szmsg = "";
Nresult = sdaskdestpath (sztitle, szmsg, szdir, 0 );
Targetdir = szdir;
Destdir = szdir;
If (nresult = back) goto dlg_setuptype;

Dlg_selmode1: // set IIS server dialog box
Sztitle = "set" + tmp_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_asksql;
If (svedit1 = false) goto dlg_asktext1; // select create virtual directory

dlg_asktext: // set the IIS server and site dialog box
sztitle = "set IIS Information Server";
szmsg = "set IIS system now ";
szquestion = "enter the host name or IP address of the server. The installer sets 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.8.8 ";
szserverportdefault =" 80 ";
setdialogtitle (dlg_ask_text, sztitle);
nresult = Digest (sztitle, szquestion, szserverip, szserverport, szserveripdefault, szserverportdefault);
If (nresult = back) goto dlg_selmode1;
If (nresult = NEXT) goto dlg_sdstartcopy1;

Dlg_asktext1: // set IIS server and create virtual directory dialog box
Sztitle = "setting IIS Information 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 = "Alias :";
Szserverport = "Directory :";
Szserveripdefault = "OA ";
Szserverportdefault = szdir;
Setdialogtitle (dlg_ask_text, sztitle );
Nresult = sdshowdlgedit2 (sztitle, szquestion, szserverip, szserverport, szserveripdefault, szserverportdefault );
If (nresult = back) goto dlg_asktext;

Dlg_sdstartcopy1: // file copy start dialog box
Sztitle = "Confirm IIS server information ";
Szmsg = "click Next to continue ";
Liststartcopy = listcreate (stringlist );
Listaddstring (liststartcopy, "User name:" + svname, after );
Listaddstring (liststartcopy, "company name:" + svcompany, after );
Listaddstring (liststartcopy, "target directory:" + szdir, after );
If (svedit1 = true) then
Listaddstring (liststartcopy, "IP Address:" + szserveripdefault, after );
Listaddstring (liststartcopy, "port:" + szserverportdefault, after );
Endif;
If (svedit2 = true) then
Listaddstring (liststartcopy, "Alias:" + szserveripdefault, after );
Listaddstring (liststartcopy, "Directory:" + szserverportdefault, after );
Endif;
Listaddstring (liststartcopy, "", after );
Listaddstring (liststartcopy, "confirm the information you entered and continue with", after );
Nresult = sdstartcopy (sztitle, szmsg, liststartcopy );
Listdestroy (liststartcopy );
If (nresult = back) goto dlg_asktext1;
Setstatuswindow (0 ,"");
Enable (statusex );
Enable (indvfilestatus );
Statusupdate (on, 100 );
If (svedit1 = true) then
Createwebsite (szserveripdefault, szserverportdefault); // start to create an IIS Site
Endif;
If (svedit2 = true) then
Createvirtualdir (szserveripdefault); // start to create an IIS Site
Endif;

End_all_install: // end all Installation
Return 0;
End;

Function onfirstuiafter ()
String sztitle, szmsg1, szmsg2, szoption1, szoption2, szjavasline;
Number bopt1, bopt2;
String szmsg;
Begin
If (nsetuptype = "fully installed") | (nsetuptype = "database only") then
// Start database creation
Createdatabase (destsvr, destsa, destpw); // create and optimize a database

If (nsetuptype = "fully installed") then
// Start setting global. asa
Openfilemode (file_mode_normal); // read-only mode for opening a file
If (openfile (nvfilehandlebak, destdir, "Global. Bak") <0) then
MessageBox ("failed to open the configuration file, please manually configure", severe );
Goto end_all_install1;
Endif;

Openfilemode (file_mode_append); // you can write data by opening a file.
If (createfile (nvfilehandle, destdir, "Global. asa") <0) then
MessageBox ("failed to create the global. Asa file, please manually configure", severe );
Goto end_all_install1;
Else // start writing files
Asaline = 1;

While (Getline (nvfilehandlebak, globalstr) = 0)
If (asaline = 15) Then // This row needs to be modified; otherwise, the file is written as is: region where the unit is located
Globalstr = "\" uninname = "+ svcompany + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 17) Then // This row needs to be modified; otherwise, the file is written as is: unit name
Globalstr = "application (\" thissoftuser \ ") = uninname & \" "+ svserial + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 18) Then // This row needs to be modified; otherwise, the file is written as is: unit name
Globalstr = "application (\" unitname \ ") = uninname & \" "+ svserial + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 30) Then // This row needs to be modified; otherwise, the file is written as is: SQL connection
Globalstr = "application (\" sqllink \ ") = \" provider = sqloledb.1; Password = "+ destpw +"; persist Security info = true; user ID = "+ destsa +"; initial catalog = OA; Data Source = "+ destsvr + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 32) Then // This row needs to be modified; otherwise, the file is written as is: SQL connection
Globalstr = "application (\" connectsql \ ") = \" driver = SQL Server; server = "+ destsvr +"; database = OA; uid = "+ destsa + "; initial catalog = OA; Pwd = "+ destpw + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 37) Then // This row needs to be modified; otherwise, the file is written as is: the Active Directory administrator account.
Globalstr = "application (\" user_sdjswoaversion \ ") = \" "+ szadusrdefault +" @ "+ szaddomaindefault + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 38) Then // This row needs to be modified; otherwise, the file is written as is: Ad administrator password
Globalstr = "application (\" password_sdjswoaversion \ ") = \" "+ szadpwddefault + "\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 61) Then // This row needs to be modified; otherwise, the file is written as is: ADIP address and organizational unit
Globalstr = "application (\" adspath_sdjswoaversion \ ") = \" LDAP: // "+ szadsvrdefault +": 389/ou = "+ szadoudefault + ", dc = "+ addc1 +", Dc = xxx, Dc = com \"";

If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

If (asaline = 62) Then // This row needs to be modified; otherwise, the file is written as is: connected to AD
Globalstr = "application (\" exchangeserver_sdjswoaversion \ ") = \" "+ szadsvrdefault +": 3268 /\"";
If (writeline (nvfilehandle, globalstr) <0) then
MessageBox ("failed to write the global. Asa file, Please modify it manually", warning );
Goto end_all_install1;
Endif;
Endif;

Asaline = asaline + 1; // The next row
Endwhile;
Endif;
// Close the file
Closefile (nvfilehandle );
Closefile (nvfilehandlebak );
Sztitle = "Create a configuration file ";
Szmsg = "congratulations, the configuration file is automatically modified! ";
Sprintfbox (information, sztitle, szmsg, "Global. asa ");
Endif;
Endif;

End_all_install1:

Disable (statusex );
Bopt1 = false;
Bopt2 = false;
Szmsg1 = sdloadstring (ifx_sdfinish_msg1 );
Szmsg2 = "";
Szoption1 = "";
Szoption2 = "";
Sztitle = tmp_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;

Dlg_rebootdialog:
Sztitle = "Welcome to install and use" + tmp_product_name + "" + tmp_product_version;
Szmsg = "The Installation Wizard has successfully installed the system. You must restart the computer before using the system. ";
Sdfinishreboot (sztitle, szmsg, sys_bootmachine, "", 0 );
Return 0;
End;

//////////////////////////
// Create and optimize a database
//////////////////////////
Function createdatabase (svsqlsvrf, svsqlusrf, svsqlpwdf)
String szcmdline, szwaittxt, tmpstr;
Begin
Szwaittxt = "Creating" + tmp_product_name + "required database ....";
Sdshowmsg (szwaittxt, true );
Delay (3 );
Szcmdline = "/u" + svsqlusrf + "/P" + svsqlpwdf + "/s" + svsqlsvrf + "/Q \" Restore database sdjswoa from disk = '"+ targetdir +" \ dB \ OA '\"";
If (launchappandwait ("osql.exe", szcmdline, wait) <0) then
Tmpstr = "database creation failed! Check that Microsoft SQL Server 2000 and SP1 are installed in your system! ";
Sprintfbox (information, "installation prompt information", tmpstr ,"");
Endif;
Sdshowmsg (szwaittxt, false );
Szwaittxt = "being optimized" + tmp_product_name + "System database ....";
Sdshowmsg (szwaittxt, true );
Delay (3 );
Szcmdline = "/u" + svsqlusrf + "/P" + svsqlpwdf + "/s" + svsqlsvrf + "/Q \" use sdjswoa; Exec sp_updatestats \"";
If (launchappandwait ("osql.exe", szcmdline, wait) <0) then
Tmpstr = "database optimization failed! Please contact the relevant personnel or install it manually! ";
Sprintfbox (information, "installation prompt information", tmpstr ,"");
Endif;
Sdshowmsg (szwaittxt, false );
Return 0;
End;

/// // create an IIS site
/// //
function createwebsite (szserveripdefault, szserverportdefault)
string szcmdline, szwaittxt;
begin
If (szserveripdefault = "") | (szserverportdefault = "")) then
MessageBox ("You have not set" + tmp_product_name + "the IP address or port of the running server !! An error occurred while setting IIS Information Service! \ N create your own IIS Site and set the main directory to "+ targetdir, severe );
else
szwaittxt = "creating IIS and setting site .... ";
sdshowmsg (szwaittxt, true);
delay (3);
sz20.line = supportdir ^" mkw3site. vbs "+"-R "+ targetdir +"-I "+ szserveripdefault +"-o "+ szserverportdefault +"-T "+ tmp_product_name;
If (launchappandwait ("wscript.exe", szcmdline, wait) <0) Then
MessageBox ("the Web virtual directory cannot be created and 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" + tmp_product_name + "virtual directory ....";
Sdshowmsg (szwaittxt, true );
Delay (3 );
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;

Function checkiis () // example: Check whether IIS is installed in the system
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;

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.