Publish a small tool: create a website and domain name binding (with code)

Source: Internet
Author: User

When we download the open source webProgramSome programs cannot run in the virtual directory. to run the program, we need to create a website, set a Host header, and then modify the host file. it is troublesome to find the file with a deep directory structure, so write down this tool.
The main technology used by gadgets is to operate IIS. There are already manyCodeIn addition, the program will automatically modify your host file. When binding an IP address, the format is IP: Port: domain.
The difficulty of creating a program is as follows: how to find the key corresponding to properties, which has no benefit for the Design Pattern of. Ms created under children.

String Entpath = String. Format ( " IIS: // {0}/w3svc " , Hostname );
Directoryentry rootentry = Getdirectoryentry (entpath ); // Obtain the IIS path
String Newsitenum = Getnewwebsiteid (); // Get new website ID
Directoryentry newsiteentry = Rootentry. Children. Add (newsitenum, " Iiswebserver " ); // Add site
Newsiteentry. commitchanges (); // Save changes to the region (changes to the site here)
Newsiteentry. properties [ " Serverbindings " ]. Value = Domainip;
Newsiteentry. properties [ " Servercomment " ]. Value = Commentofwebsite;
Newsiteentry. properties [ " Accessread " ] [ 0 ] =   True ;
Newsiteentry. properties [ " Accessexecute " ] [ 0 ] =   True ;
Newsiteentry. properties [ " Apppoolid " ] [ 0 ] =   " Defaultapppool " ;


// Newsiteentry. properties ["accesswrite"] [0] = true;
Newsiteentry. commitchanges ();
Directoryentry vdentry = Newsiteentry. Children. Add ( " Root " , " Iiswebvirtualdir " );
Vdentry. commitchanges ();
Vdentry. properties [ " Path " ]. Value = Webpath;
Vdentry. commitchanges ();

Vdentry. Invoke ( " Appcreate " , 1 );

The entire program is relatively simple and interested in downloading code.

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.