Installshield12 create a custom web site

Source: Internet
Author: User

Task: Use installshield12 installscript MSI project to package ASP. NET ApplicationsProgramTo create a custom site.

Step: 1. Create the property of webname.

2. Configure IIS In the IDE of is, for example:

Set the WEB virtual directory to [webname]. The value of this attribute will be used after installation, and the website name can also be represented by attributes. Note: When a site is created, port 80 is created by default. If a site with port 80 already exists, the virtual directory will be created under the site with port 80 in is, (This is exactly what I want. For example, it will be created under the default web site by default ). other virtual diecloud settings and permission settings are equivalent to those set in IIS.

3. Use a script to get the name of the virtual directory entered by the user
Use the sdshowdlgedit1 dialog box to obtain the name entered by the user, assign a value to the webname property, and use the property method.

About uninstallation: After the User-Defined name is used, the uninstallation is not clean. I have not found a good way to unmount the virtual directory in IIS. I believe there is a simple way to do this, just like when you create it. The following is my uninstall script (writelog is my custom method, and adsutil. vbs can be found under c: \ Inetpub \ adminscripts ). Pass the name of the virtual directory to be deleted into delvirtualondefault:

  //////////////////////////////////////// /////////////////
// Function : Delw.ul
// Purpose: delete virtual directories
// Arguments: szwebname - Byref
// Usage:
// Note: w3svc / 1 / Root / Webname is the virtual directory under 1
//////////////////////////////////////// /////////////////
Function Delw.ul (webname, virtualfolder)
String Szcmdline, szcmd, szcmdline2, szmsg;
Number nresult;
Begin
Szcmd = Windowsfolder ^   " System32 "   ^   " Cscript.exe " ;
Szcmdline = Supportdir ^ " Adsutil. vbs Delete w3svc/ " + Webname + " /Root/ " ^ Virtualfolder;
Szcmdline2 = Supportdir ^ " Adsutil. vbs Delete w3svc/1/root/ " ^ Virtualfolder;
Nresult = Launchappandwait (szcmd, szcmdline, Nowait | laaw_option_hidden );
Sprintf (szmsg, " Run " + Szcmdline + " Result is % LD " , Nresult );
Writelog (szmsg );
Nresult = Launchappandwait (szcmd, szcmdline2, Nowait | laaw_option_hidden );
Sprintf (szmsg, " Run " + Szcmdline2 + " Result is % LD " , Nresult );
Writelog (szmsg );
Writelog ( " Del virtualfolder: " + Virtualfolder + " On: " + Webname );
End ;

  //////////////////////////////////////// /////////////////
// Function : Delvirtualondefault
// Purpose: Delete the virtual directory of the site created on port 80 by default.
// Arguments: virtualfolder - Virtual directory name
// Usage:
// Note: isgetobj. dll must be referenced.
//////////////////////////////////////// /////////////////
Prototype isgetobj. vbgetobject (byval String , Byval String , Byref Object );
Prototype isgetobj. foreachstart (byref Object , Byref variant );
Prototype isgetobj. foreachgetnextitem (byref variant, byref Object );
//////////////////////////////////////// //////////////////
Prototype delvirtualondefault ( String );
  Function Delvirtualondefault (virtualfolder)
  Object Objiis_root, obj1_dir, objwebservice, objwebsite;
Number nresult, ncount, nindex;
Variant vtemp, strtemp, strtemp2;
Variant _ varenumholder; // Hold ienumvariant during the foreachloop, Don ' T use object type, this is an iunknown !!
Begin
Usedll (supportdir ^   " Isgetobj. dll " );
Set Objwebservice = Cogetobject ( " IIS: // localhost/w3svc " , "" );
If   Isobject (Objwebservice) Then
Foreachstart (objwebservice, _ varenumholder );
Nresult = Foreachgetnextitem (_ varenumholder, objwebsite );
While (Nresult = Error_success)
If   Isobject (Objwebsite) Then
If Objwebsite. Class =   " Iiswebserver "   Then

Vtemp = Objwebsite. serverbindings;
Strtemp = Vtemp ( 0 );
If (Strtemp = " : 80: " ) Then
// Locate the site name under port 80
Strtemp2 = Objwebsite. Name;
Writelog ( " Webname: " + Strtemp2 );
Delstmul (strtemp2, virtualfolder );
Endif;
Endif;
Endif;
Nresult = Foreachgetnextitem (_ varenumholder, objwebsite );
Endwhile;
Endif;
Unusedll ( " Isgetobj. dll " );
  End ;
  /*************************************** ************/

Because installscript does not contain for each, a custom dll: isgetobj. dll is called.

Download: isgetobje. dll file

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.