cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Aaron_Barnett
Level 5

Get a list of all IIS websites from IIS

Hi,

I am using InstallScript.

I am trying to give the Option to the user to Create New or Use an Existing website to install the web application to in IIS.

Create a new website - fine
Use an Existing website - i need to get the Name and the ID and populate a dropdown list.

I am trying to build a list of all IIS website names and ID numbers.

e.g.
'Default website' 0
'new website' 1
'new website2' 2

Has anyone done this with Installshield?

Thanks.

-Aaron
Labels (1)
0 Kudos
(8) Replies
Alpesh
Flexera Alumni

Hi,

Please refer to this kb article --> http://kb.flexerasoftware.com/selfservice/viewContent.do?externalId=Q111053. It has a sample VB Script code to retrieve the list of websites.

Thanks,
Alpesh
0 Kudos
Aaron_Barnett
Level 5

Thanks for that Link Aplesh,

Is this the best way to run VB code from InstallScript?
FindFile(WINSYSDIR, "WScript.exe", sWScript);
if sWScript != '' then
LaunchAppAndWait(WINSYSDIR ^ "WScript.exe", SUPPORTDIR ^ "getIssWebsites.vbs", WAIT);
endif;


When i run the VB code:
Dim objViewDim objRecordDim objW3SVC, objIisWebSiteDim lngOrderSet objView = Session.Database.OpenView("select * from ComboBox")
' enumerate webservers on localhost and populate ComboBox tableSet objW3SVC = GetObject("IIS://localhost/W3SVC")lngOrder = 1
For Each objIisWebSite In objW3SVCIf objIisWebSite.Class = "IIsWebServer" Then If LCase(objIisWebSite.ServerComment) <> "administration web site" Then
' add site name to ComboBox table (which is used by our dialog ComboBox) Set objRecord = Session.Installer.CreateRecord(4) objRecord.StringData(1) = "WT1_IISWebSite" ' property name objRecord.IntegerData(2) = lngOrder ' order objRecord.StringData(3) = objIisWebSite.Name ' value objRecord.StringData(4) = objIisWebSite.ServerComment ' text
' now add the record to the table objView.Modify 7, objRecord ' (7 = msiViewModifyInsertTemporary) lngOrder = lngOrder + 1 End IfEnd If
NextobjView.Close


I get a error message:
Line: 1
Char: 16
Error: Expected end of statement
code: 800A0401


Any ideas?
0 Kudos
gprasadholla
Level 4

This will help if you are planning to implement it in a custom action through a DLL.

http://floatingant.blogspot.com/2010/03/listing-all-websites-installed.html

Just in :rolleyes: case..
0 Kudos
Aaron_Barnett
Level 5

Sorry?

Is there a way of calling this custom DLL instead of using VB Script?

Where can i find more info on doing this?
0 Kudos
Aaron_Barnett
Level 5

Sorry?

Is there a way of calling this custom DLL instead of using VB Script?

Where can i find more info on doing this?


1. Do i just create a text file and rename it .dll?

2. how do i add it to installshield?

3. how do i call it?
0 Kudos
gprasadholla
Level 4

Yes you can.

Readup "Calling a .dll File Function" article from Installshield Help.
0 Kudos
Aaron_Barnett
Level 5

Thanks for the help gprasadholla
0 Kudos
Aaron_Barnett
Level 5

That DLL Dosnt have a function, Can i call it by going

UseDLL( SUPPORTDIR ^ "MyDLL.dll" );
bResult = MyDLL.MyFunction( nInt1, nInt2, nInt3 );

Can i call this DLL without it having a function?

System::String* entryName = System::String::Format(S"IIS://{0}/w3svc", computerName);
System::Text::StringBuilder* sb = new System::Text::StringBuilder(512);
System::DirectoryServices::DirectoryEntry* rootEntry = NULL;
System::DirectoryServices::DirectoryEntry* childEntry = NULL;
try
{
rootEntry = new System::DirectoryServices::DirectoryEntry(entryName);
rootEntry->RefreshCache();
System::Collections::IEnumerator* iterator = rootEntry->Children->GetEnumerator();
while(iterator->MoveNext())
{
childEntry = dynamic_cast<:DIRECTORYSERVICES::DIRECTORYENTRY>(iterator->Current);
if(!childEntry->Name->Equals( S"AppPools", System::StringComparison::CurrentCultureIgnoreCase ))
{
if(!childEntry->Name->Equals(S"Filters", System::StringComparison::CurrentCultureIgnoreCase))
{
if(!childEntry->Name->Equals(S"Info", System::StringComparison::CurrentCultureIgnoreCase))
{
//Print childEntry->Name;
}
}
}
}
}
0 Kudos