Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Create Virtual Directory  using CA


6 replies to this topic

Kannan

Kannan
  • Members
  • 22 posts

Posted 03 July 2001 - 10:01

Hi All
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.

Victorz

Victorz
  • Members
  • 32 posts

Posted 03 July 2001 - 12:10

try this function :

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


Kannan

Kannan
  • Members
  • 22 posts

Posted 13 July 2001 - 05:35

Hi
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.


Victorz

Victorz
  • Members
  • 32 posts

Posted 15 July 2001 - 10:13

the problem you describe is strange - I never encountered such a problem.
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.

BobRouse

BobRouse
  • Members
  • 82 posts

Posted 07 August 2001 - 19:07

When using the Internet Service Manager, make sure you right-click on your "Default Web Service" and select "Refresh".

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



tbrinkm

tbrinkm
  • Members
  • 10 posts

Posted 11 September 2001 - 19:28

I'm just learning ISWI, so I'm probably asking a stupid question here, but what do you need to do in order to pass parameters to the custom action created with the first sample function here?  I've created the function, but I don't see how to pass the two parameters into it.