Create Virtual Directory using CA
Posted 03 July 2001 - 10:01
i am using IPWI 2.01. i want to create a virtual directory in the target machine.i wrote a vb script for this. then i created a CA for this.After this i add that CA into Execute sequence. while running the setup, the Virtual directory is created sometime correctly. sometimes it isnot be created. what will be the reason for this. if any correct VBscript for this is appriciated.
Posted 03 July 2001 - 12:10
function CreateVirtualFolder(sName,sPath)
Dim oIIS, oDir
Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
On Error Resume Next
Set oDir = oIIS.GetObject("IISWebVirtualDir", sName)
' This will return error -2147024893 if it doesn't exist
If Err.Number <> 0 Then Set oDir = oIIS.Create("IISWebVirtualDir", sName)
Err.Clear
oDir.AccessScript = True
oDir.Path = sPath
' Workaround for bug in II4
oDir.KeyType = "IIsWebVirtualDir"
oDir.SetInfo
oDir.AppCreate True
oDir.SetInfo
Set oDir = Nothing
Set oIIS = Nothing
end function
Posted 13 July 2001 - 05:35
i used ur VB Script for a CA.after installing my produvt i check for the Virtual Dir.it is not created.but when i run the script alone using CScript.exe, virtual dir not created. but then i stop the webserver and again started it. after that i run the VBScript.now Virtual Dir was created.i coulnot understand the problem.this is happening now and then.befor creating the virtual dir,does i stop and start the webserver. Pl reply imm.
Posted 15 July 2001 - 10:13
are you using IIS 5 or 4 - maybe the IIS did something before you created the virtual dir that stopped its refresh ? , maybe the refresh isn't working properly on that IIS ? - please check it and tell me.
Posted 07 August 2001 - 19:07
Also: FYI... I use the following VB function to create the virtual directory. For me, it is compiled into an ActiveX DLL, but it should work as VB script as well. I actually create the physical directory first before calling this function:
Public Function CreateVirDir(ByVal strDir As String, ByVal strPath As String, ByVal bDisableAnonLogin As Boolean) As Boolean
On Error GoTo ErrHandler
Dim objIIS As Object
Dim objDir As Object
Dim strSubDir As String
Dim strVirPath As String
strSubDir = Trim$(strDir)
strVirPath = Trim$(strPath)
' Initialize connection to IIS
Set objIIS = CreateObject("IIS://localhost/W3SVC/1/Root")
' --- Get the virtual dir object, create it if it doesn't exist. ---
On Error Resume Next ' This is because the next line WILL error if dir does not exist
' This will return error -2147024893 if it doesn't exist
Set objDir = objIIS.GetObject("IIsWebVirtualDir", strSubDir)
' if errored, then create
If Err.Number = -2147024893 Then
On Error GoTo ErrHandler
Set objDir = objIIS.Create("IIsWebVirtualDir", strSubDir)
Else
On Error GoTo ErrHandler
End If
objDir.AccessScript = True
objDir.Path = strVirPath
' Workaround for bug in II4
objDir.KeyType = "IIsWebVirtualDir"
objDir.SetInfo
If bDisableAnonLogin Then
objDir.Authanonymous = False
objDir.SetInfo
objDir.AuthNTLM = True
objDir.SetInfo
End If
CreateVirDir = True
CloseUp:
Set objIIS = Nothing
Set objDir = Nothing
Exit Function
ErrHandler:
strErrMsg = Err.Description
CreateVirDir = False
GoTo CloseUp
' for testing purposes only
Resume
End Function
Posted 11 September 2001 - 19:28