InstallShield and Microsoft IIS
Posted 20 April 2001 - 15:34
But, when they are created, you have to right click on them and go to Properties and make many changes.
How can this be done in InstallShield?
From the command line?
Whats the syntax?
Please help.
Posted 21 April 2001 - 06:55
For details on the properties and their settings, look up IIsWebVirtualDir in MSDN.
If you have any problems, let me know and I can send you an example script.
Posted 17 May 2001 - 21:11
I found some sample code in the MSDN, and I developed a script based on that which worked fine on one machine but fails on pretty much every other machine.
In the scripts, I take the following steps (with added error checking, of course):
Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
Set DirObj = GetObject("IIS://LocalHost/W3SVC/1/ROOT/dsa")
If Err.Number <> 0 Then Set DirObj = oIIS.Create("IISWebVirtualDir", "dsa")
DirObj.AppCreate INPROC
.
.
.
where "dsa" is the name of the directory under "wwwroot" that I want to make the app of.
I had it working fine on one machine, but it fails miserably on every other. It says that the path doesn't exist for the first line above.
When I remove the 1/Root from both of the first 2 lines, and have:
Set oIIS = GetObject("IIS://localhost/W3SVC")
Set DirObj = GetObject("IIS://LocalHost/W3SVC/dsa")
Those two lines work, but I get an error saying that AppCreate is not a valid method or property.
I now cannot find the page in the MSDN where I got the sample.
Can someone shed some light on this?
Posted 17 May 2001 - 23:25
Posted 18 May 2001 - 19:57
When I use the following code:
Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
' Get the virtual dir object, create it if it doesn't exist.
On Error Resume Next
Set DirObj = oIIS.GetObject("IIsWebVirtualDir", "dsa")
' This will return error -2147024893 if it doesn't exist
If Err.Number <> 0 Then
MsgBox ("Directory doesn't exist...creating dsa")
Set DirObj = oIIS.Create("IIsWebVirtualDir", "IIS://localhost/W3SVC/1/Root/dsa")
End If
In theory, it would try to get the directory object, and if it doesn't yet exist, it will then go and create it.
If I physically create the directory under wwroot then run this script, it will fail with "unspecified error" on the call to Create.
The funny thing is that if I go into the IIS manager, and modify one property (any property) of the directory in question, before running the script, then the script will succeed.
So, bearing this in mind, it looks like I'm missing one very important step in the process...a step that IIS manager is doing when I set that property.
Can anyone tell me what's missing?
Posted 07 August 2001 - 19:10
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