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

InstallShield and Microsoft IIS


6 replies to this topic

Travis2001

Travis2001
  • Members
  • 3 posts

Posted 20 April 2001 - 15:34

In InstallShield I can create two directories that show up under Default Web Site in IIS.
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.

Leigh Ravenhall

Leigh Ravenhall
  • Members
  • 269 posts

Posted 21 April 2001 - 06:55

I use a VBScript custom action for creation of IIS Virtual directories.  In this script, I then set properties such as authentication details, threading options, execute script permissions, etc.  I think all of the changes that can be made by setting properties through the interface can be set through script.

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.


Brad Younie

Brad Younie
  • Members
  • 6 posts

Posted 17 May 2001 - 21:11

I'm trying to do the same thing, but am having some trouble.

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?


Leigh Ravenhall

Leigh Ravenhall
  • Members
  • 269 posts

Posted 17 May 2001 - 23:25

Failing on the first line with a nonexistent path error could mean that the web server doesn't exist.  Have a look in IIS, check whether it exists.  If you have a default installation, it is normally called something along the lines of "Default Web Site".

Brad Younie

Brad Younie
  • Members
  • 6 posts

Posted 18 May 2001 - 19:57

Okay, so I'm replying to my own post. This is because I've narrowed it way down.

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?


BobRouse

BobRouse
  • Members
  • 82 posts

Posted 07 August 2001 - 19:10

I don't know what you might be doing wrong, but I know this function works; it's what I use. I compile it into an ActiveX DLL, but it should work as a VB script as well. Note: I physically create the dir first:

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