"' *******************************************************
"Create a webserver
"Required Parameters: Wroot, to create the physical directory of the site; wcomment for the site description; Wport is the site port; Serverrun to run automatically
"" returns 1 when creation succeeds, prompts to exit when failed and returns 0, returns 2 when the site is created successfully but fails to start
"' *******************************************************
"**************** Note: Wport is a list type, meaning server port *************
' This function is passed on IIS5.0, * * must be logged in as an administrator * *
"Port Example:
"Dim Wport,bindlists,createflag,ocomputer
" ocomputer=" LocalHost "
"Binglists=array (0)
" binglists (0) =": 80: "" The port number is
"' Wport=binglists
" createflag=createwebserver (" D:\myweb "," My Homeland ", Wport,false)" Call the Build station function
"If creatflag=0 Then
' Response.Write ' failed to create the site! Please determine if you have permission "
"' ElseIf createflag=1 Then
"Response.Write" created the site successfully! "
"' ElseIf createflag=2 Then
' Response.Write ' created the site successfully, but failed to start the site, possibly Port conflict! "
' End If
"' ********************************************************************************
"about the creation of the FTP site I have published in the ASP version, please have interested friends to see for themselves
Function Createwebserver (Wroot,wcomment,wport,serverrun)
On Error Resume Next
Dim Serviceobj,serverobj,vdirobj
Set serviceobj = GetObject ("iis://" &oComputer& "/w3svc") "first create a service instance
Wnumber=1
Do While IsObject (Serviceobj.getobject ("IIsWebServer", Wnumber))
If Err.number<>0 Then
Err.Clear ()
Exit do
End If
Wnumber=wnumber+1
Loop
Set ServerObj = serviceobj.create ("IIsWebServer", Wnumber) "and then create a Web server
if (err.number <> 0) then "error
' Response.Write ' ERROR: The ADSI operation to create the Web server failed! "
Createwebserver=0
Exit Function
End If
"Then configure the server
Serverobj.serversize = 1 "Medium size
Serverobj.servercomment = Wcomment ' description
serverobj.serverbindings = Wport ' Port
Serverobj.enabledefaultdoc=true
"Submit Information
Serverobj.setinfo
"Finally, create a virtual directory
Set vdirobj = serverobj.create ("IIsWebVirtualDir", "ROOT")
if (err.number <> 0) then "error
' Response.Write ' ERROR: The ADSI operation to create the virtual directory failed! "
Createwebserver=0
Exit Function
End If
' Configure Virtual directories
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 then
ServerObj.Start
If (err.number <> 0) Then ' error!
' Response.Write ' ERROR: An error occurred while starting the server! Please start webserver "&WComment&" Manually! <br> "&NBSP;
createwebserver=2
Exit function
End if
End if
Set vdirobj =nothing
set serverobj=nothing
set serviceobj=nothing
createwebserver=1
End Function