Oprettelse af et Site i klassen IISSiteManagement:
Public Function CreateSite(ByVal TargetComputer As String, ByVal IISService As String, ByVal SiteName As String, ByVal SitePath As String) As Boolean
Dim Parent As IADs
Dim Child As Variant
Dim NewSite As IADs
Dim NewRoot As IADs
Dim Index As Double
Select Case UCase(IISService)
Case "WWW"
Set Parent = GetObject("
IIS://" & TargetComputer & "/W3SVC")
Case "FTP"
Set Parent = GetObject("
IIS://" & TargetComputer & "/MSFTPSVC")
Case "SMTP"
Set Parent = GetObject("
IIS://" & TargetComputer & "/SMTPSVC")
Case "NNTP"
Set Parent = GetObject("
IIS://" & TargetComputer & "/NNTPSVC")
End Select
For Each Child In Parent
If IsNumeric(Child.Name) Then
If Index < Child.Name Then
Index = Child.Name
End If
End If
Next
Index = Index + 1
Select Case UCase(IISService)
Case "WWW"
Set NewSite = Parent.Create("IIsWebServer", Index)
NewSite.ServerComment = SiteName
NewSite.approot = SitePath
NewSite.SetInfo
Set NewRoot = NewSite.Create("IIsWebVirtualDir", "Root")
NewRoot.Path = SitePath
Err.Number = 0
NewRoot.SetInfo
Case "FTP"
Set NewSite = Parent.Create("IIsFTPServer", Index)
NewSite.ServerComment = SiteName
NewSite.SetInfo
Set NewRoot = NewSite.Create("IIsFTPVirtualDir", "Root")
NewRoot.Path = SitePath
Err.Number = 0
NewRoot.SetInfo
End Select
If Err.Number = 0 Then CreateSite = True
End Function
Oprettelse af et Site i den mappede klasse:
Function CreateWWWSite(Servername As String, SiteName As String, SitePath As String, Optional IndexServer = True) As Boolean
Dim Site As New IISAdmin.IIsSiteManagement
Dim res As Boolean
Dim SiteIndex As Double
On Error Resume Next
IISFunc.MakeDirPath (SitePath)
CreateWWWSite = Site.CreateSite(Servername, "WWW", SiteName, SitePath)
SiteIndex = GetWWWSiteIndex(Servername, SiteName)
If IndexServer Then VirDir_SetIndexing "Root", Servername, True, "WWW", SiteIndex
End Function
Håber det giver lidt inspiration :-)