Her er hele scriptet:
<%
' Make connections to WMI, to the IIS namespace on MyMachine, and to the Web service.
set locatorObj = Server.CreateObject("WbemScripting.SWbemLocator")
set providerObj = locatorObj.ConnectServer("MyMachine", "root/MicrosoftIISv2")
set serviceObj = providerObj.Get("IIsWebService='W3SVC'")
' Build binding object, which is a required parameter of the CreateNewSite method.
' Use the SpawnInstance WMI method since we are creating a new instance of an object.
Bindings = Array(0)
Set Bindings(0) = providerObj.get("ServerBinding").SpawnInstance_()
Bindings(0).IP = "1.2.4.5"
Bindings(0).Port = "80"
Bindings(0).Hostname = "test.dk"
' Create the new Web site using the CreateNewSite method of the IIsWebService object.
Dim strSiteObjPath
strSiteObjPath = serviceObj.CreateNewSite("test.dk", Bindings, "c:\inetpub\wwwroot")
If Err Then
Response.write "*** Error Creating Site: " & Hex(Err.Number) & ": " & Err.Description & " ***"
stop
End If
' strSiteObjPath is in the format of IIsWebServer='W3SVC/1180970907'
' To parse out the absolute path, W3SVC/1180970907, use the SWbemObjectPath WMI object.
Set objPath = server.CreateObject("WbemScripting.SWbemObjectPath")
objPath.Path = strSiteObjPath
strSitePath = objPath.Keys.Item("")
' Set some properties on the root virtual directory which was created by CreateNewSite.
Set vdirObj = providerObj.Get("IIsWebVirtualDirSetting='" & strSitePath & "/ROOT'")
vdirObj.AuthFlags = 5 ' AuthNTLM + AuthAnonymous
vdirObj.EnableDefaultDoc = True
vdirObj.DirBrowseFlags = &H4000003E ' date, time, size, extension, longdate
vdirObj.AccessFlags = 513 ' read, script
vdirObj.AppFriendlyName = "Default Application"
' Save the new settings to the metabase
vdirObj.Put_()
' CreateNewSite does not start the server, so start it now.
Set serverObj = providerObj.Get(strSiteObjPath)
serverObj.Start
Response.write ("A New site called MyNewSite was created with the path and unique site identification number of " & strSitePath & "")
%>
Det er script der opretter et website på en iis, og hostname skal jo være både test.dk og
www.test.dk, så jeg skal have en måde at begge værdier kan komme med
Håber det hjælper lidt