Programmatically use ASP to establish a Web site in IIS

xiaoxiao2021-03-06  87

'' ********************************************************* ******* '' Create a webserver '' must parameter: Wroot, for the physical directory of the site; WComment is a site description; WPORT is the site port; ServerRun is automatically run "Returns 1 when the creation is successful, When you fail, you prompt and return 0. When you create a site success but return 2 '' ***************************************************** ************************ '*************** Note: WPORT is the list type, Means the server port ************* 'This function is passed on IIS5.0, ** must log in to the administrator **' port example: '' DIM WPORT, BINDLISTS, CreateFlag, Ocomputer '' OComputer = "localhost" '' binglists = array (0) '' binglists (0) = ": 80:" 'port number 80' 'wport = binglists'' createflag = CreateWebServer ("D: / myWeb, "My Home", WPORT, FALSE) '' Calling Station Function '' 'IF Creatflag = 0 THEN' '' RESPONSE.WRITE "Created Site Failed! Please determine if there is permission" 'Elseif CreateFlag = 1 Then' 'Response.write "Create Site Success!"' 'Elseif Createflag = 2 TEN' 'RESPONSE.WRITE "Create a site success, but the startup site failed, possible port conflicts!"' End if '' ******* *********************************************************** ********************** "about the creation of the FTP site I have published in the ASP version, please have interest to see yourself

Function CreateWeb Server (Wroot, WComment, Wport, Serverrun) on Error Resume Next Dim ServiceObj, Serverobj, Vdirobj Set ServiceObj = getObject ("IIS: //" & OboTer & "W3SVC") '' Create a service instance

Wnumber = 1 do while isobject (ServiceObj.getObject ("IisWebserver", Wnumber) f err.Number <> 0 Then Err.clear () exit do end if wnumber = WNUMBER 1 LOOP

SET ServerObj = serviceObj.create ("IisWeb Server", then create a web server if (err.Number <> 0) Then '' error '' response.write "error: Create a web server ADSI operation failed! "CREATEWEBSERVER = 0 exit function endiff

'' Configuring server serverobj.serversize = 1 '' medium size serverobj.servercomment = wcomment '' Description Serverobj.ServerBindings = WPORT 'port serverobj.enableDefaultdoc = TRUE

'' Submit information serverobj.setInfo

'' Finally, establish a virtual directory set vdirobj = serverobj.create ("IisWebVirtualdir", "root")

If (Err.Number <> 0) THEN '' error '' response.write "error: Create a virtual directory ADSI operation failed!" CREATEWEBSERVER = 0 exit function endiff

'' Configure virtual directory VDirObj.Path = WRoot VDirObj.AccessRead = True VDirObj.AccessWrite = True VDirObj.EnableDirBrowsing = False VDirObj.EnableDefaultDoc = True VDirObj.Accessscript = True VDirObj.AppCreate2 2 VDirObj.AppFriendlyName = "default application" VDirObj. SetInfo

IF serverrun = true kilobj.startiff (Err.Number <> 0) Then '' Error! '' Response.Write "Error: An error occurred while starting the server manually start WebServer!" & WComment & CreateWebServer = 2 Exit Function End If End If Set VDirObj = Nothing Set ServerObj = Nothing Set ServiceObj = Nothing CreateWebServer = 1 End "
!" FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-121779.html

New Post(0)