Hello chak,
I have created a reusable class called IISAdmin. Hope this helps.
Const IIS_PATH = "IIS://localhost/w3svc/1/root"
Class IISAdmin
Private m_IIS
Private Sub Class_Initialize
On Error Resume Next
Set m_IIS = GetObject(IIS_PATH)
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly + vbExclamation, APP_NAME
Err.Clear()
Exit Sub
End If
End Sub
Private Sub Class_Terminate
On Error Resume Next
If Not m_IIS Is Nothing Then
Set m_IIS = Nothing
End If
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly + vbExclamation, APP_NAME
Err.Clear()
Exit Sub
End If
End Sub
' ******************************************************************
Public Sub CreateVirtualDirectory(ByVal VirDirName, ByVal LocalPath)
Dim NewVirDir
Set NewVirDir = m_IIS.Create("IIsWebVirtualDir", VirDirName)
NewVirDir.Path = LocalPath
NewVirDir.SetInfo
NewVirDir.AppCreate True
NewVirDir.SetInfo
If Not NewVirDir Is Nothing Then
Set NewVirDir = Nothing
End If
End Sub
Public Sub DeleteVirtualDirectory(ByVal VirDirName)
On Error Resume Next
Dim VirDir
Set VirDir = m_IIS.Delete("IIsWebVirtualDir", VirDirName)
VirDir.AppDelete
m_IIS.SetInfo
Err.Clear()
End Sub
End Class