splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

List all IIS Virtual Directories

Hi Guys,

I am wondering, do you have an example code to list all the virtual directories under IIS?


I want the user to select which virtual directory to install into, here is my attempt which doesnt work.


OPTION EXPLICIT
Set db = Session.Database

DIM CRLF, TAB
DIM strServer
DIM objWebService
DIM combo

TAB = CHR( 9 )
CRLF = CHR( 13 ) & CHR( 10 )
combo = "CRMInstanceComboBox"

IF WScript.Arguments.Length = 1 THEN
strServer = WScript.Arguments( 0 )
ELSE
strServer = "localhost"
END IF


SET objWebService = GetObject( "IIS://" & strServer & "/W3SVC" )
EnumWebsites objWebService
MsgBox( "Yes" )

SUB EnumWebsites( objWebService )
DIM objWebServer, strBindings, index
index = 1
FOR EACH objWebServer IN objWebService
IF objWebserver.Class = "IIsWebServer" THEN
AddToCombo combo, index, objWebserver
index = index + 1
END IF
NEXT

END SUB

SUB AddToCombo( combo, index, objWebserver )

SQLCmd = "INSERT INTO " & combo & " (`Property`,`Order`,`Value`,`Text`)"
SQLCmd = SQLCmd & " VALUES ('CRMINSTANCE_PROP','" & index & "','" & objWebserver.Name & "','"
SQLCmd = SQLCmd & objWebserver.Name & "') TEMPORARY"
Set view = db.OpenView( SQLCmd )
view.Execute
END SUB


Really Really Really appreciate the help.


Tony
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

I'm not sure what exactly are you trying to do, but here is a VBScript example to start from (this script enumerates all Virtual Directories from the "Default Web Site"):

Code: Select all

' List all Virtual Directories of "Default Web Site" (1)

Set objIIsWebSite = GetObject("IIS://localhost/W3SVC/1/ROOT")

For Each VDir in objIIsWebSite
If VDir.Class = "IIsWebVirtualDir" Then
Set objIIsWebSite = GetObject(VDir.ADsPath)

MsgBox "Virtual Directory: " & VDir.Name
End If
Next
Regards,
Gigi
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com/
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Sorted

That is absolutly brilliant

I changed it to

WScript.Echo "Virtual Directory: " & VDir.Name & " " & objIIsWebSite.Path

I want to list all the current virtual directories in a dropdown and install my app into the real path of the virtual directory chosen.

Thanks
Sreeram
Posts: 26
Joined: Mon Aug 17, 2015 12:19 pm

Re: List all IIS Virtual Directories

It would be a great help if you kindly post the sample project with custom action for the same.

Regards
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: List all IIS Virtual Directories

Hello,

Please note that in our latest Advanced Installer version there is no need to write your own custom action to browse for virtual directories. Now you can achieve this by using our "Browse IIS" predefined support.

Just go to "IIS" page, select the "IIS Browse" tree node and from its context menu choose "New IIS Browse -> Web Sites" option. Then, in the "IIS Web Site Browse" right pane -> "Browse Type" combo box choose the "Virtual Directories" option.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”