- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How to install a web application to different websites in IIS based on a condition
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
How to install a web application to different websites in IIS based on a condition
Hello there,
We have an IIS web application which has been released to customers and it is installed under the DefaultWebSite with file path under c:\inetpub\wwroot\.
For the next release, we would like to support two modes 1) upgrading install 2) fresh new install.
1) Upgrading install
For customers who have this application installed, it will install the new release to its current website and to its current physical path.
2) Fresh new install
For new customers, the application should be installed under MyWebSite and new physical path such as C:\myCompany\mywebsite\myApp.
We would like the Installer dynamically check the presence of the web application on the client machine and perform Upgrading or Fresh New Install seamlessly.
In a short summary, I need to know how to achieve the following in Installshield:
1) If a condition is true, programmatically modify the target WebSite to be WebSiteA, otherwise to be WebsiteB.
2) If a condition is true, programmatically set the installation destination folder to folderA, otherwise to folderB.
The current Installer file has Scripts and Custom Actions. I am new to installshield. Any help is appreciated!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi,
You can implement this by writing installscript code.Here are some information that can help:
- You can detect specific website's installation by searching an entry in applicationhost.config(C:\Windows\System32\inetsrv\config\applicationHost.config)
- Based on website's existence,you can set INSTALLDIR property of website as <New Value> or existing value( c:\inetpub\wwroot\)
- You can try setting IIS properties using MsiSetProperty/TextSubSetValue as mentioned in the below article:
https://helpnet.flexerasoftware.com/installshield20helplib/Content/helplibrary/IIS-MSIProps.htm
Hope it helps,
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hello Jenifer,
Thank you for your reply. I have been testing your suggestions.
Based on my testing, I have a few more questions:
1) Is there an API in install script to retrieve the web site information from applicationhost.config ?
2) May you please show me an example on how to reset the INSTALLDIR to a new value?
3) If I created an Website in MyWebSite and the web app is MyApp in Installer Designer/Server Configuration/Internet Information Service, how can I retrieve this WebSite in InstallScript and set the MyWebSite to a new name such as "MyWebSite2"?
4) Based on my testing, it seems like that I have to set the "MyWebSite" to be a new site number to create it during installation. If I set the SiteNumber to be "0", it treats it as the "Default Web Site". I tried to set it to be the "INSTALLSHIELD_IIS_NEXT_NEW_SITE_NUMBER", it did not work. It throw an error during installation. How should I get the next number and how can I set this number in the script code?
5) Based on my testing, to be able to create a new site and make the new site accessible, I also need to modify the C:\WINDOWS\System32\drivers\hosts file to add the new site to this file. Does Install Shield provide an API to modify this file?
Thank you for your help.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @AceBear ,
Answering to your questions:
Is there an API in install script to retrieve the web site information from applicationhost.config ?-No,you can have Managed custom action to this job via writing .Net dll that can read values from it.Some links to help you with:
Note:You can also achieve it via VBScript custom action by writing VB code,i had attached sample vbscript files which will create IIS-Virtual directory and Set properties.You can refer the same for application/website creation.Follow the instructions given in file.
May you please show me an example on how to reset the INSTALLDIR to a new value?:
- You can create a new property entry named Eg:CustomINSTALLDIR under Property table by navigating to Direct Editor->Property
- Give the newly created property entry inside angular bracket <CustomINSTALLDIR> under your application content Source path as <IISROOTFOLDER>\<CustomINSTALLDIR>
- Inside your script,try setting the value using the function
- string svDirValue;//Which ever value you want to set based on condition check from ApplicationHost.config
- TextSubSetValue("<CustomINSTALLDIR>",svDirValue, TRUE );
- This will do the job for you.
If I created an Website in MyWebSite and the web app is MyApp in Installer Designer/Server Configuration/Internet Information Service, how can I retrieve this WebSite in InstallScript and set the MyWebSite to a new name such as "MyWebSite2"?:
- You are only creating website know,why do you want to change the value?
Based on my testing, it seems like that I have to set the "MyWebSite" to be a new site number to create it during installation. If I set the SiteNumber to be "0", it treats it as the "Default Web Site". I tried to set it to be the "INSTALLSHIELD_IIS_NEXT_NEW_SITE_NUMBER", it did not work. It throw an error during installation. How should I get the next number and how can I set this number in the script code?
- Can you try the same approach of creating property and setting the value using TextSubSetValue?Please follow the below links for more information:
- https://helpnet.flexerasoftware.com/installshield22helplib/helplibrary/IIS-MSIProps.htm?
- https://helpnet.flexerasoftware.com/installshield19helplib/helplibrary/IIS-TextSub.htm
Based on my testing, to be able to create a new site and make the new site accessible, I also need to modify the C:\WINDOWS\System32\drivers\hosts file to add the new site to this file. Does Install Shield provide an API to modify this file?
- You can use installshield's Internet Information Services.Why do you want to create by your own from code?InstallShield doesn't provide any API to do this.
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you very much for these information. It is very cool. I will dig into it. I am sure that I will have a few more questions later.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
It seems that there are two ways to set a property:
MsiSetProperty(ISMSI_HANDLE, "IS_UPGRADE_INSTALL", "2"); // 1: New Install; 2: Upgrade
TextSubSetValue("<IS_UPGRADE_INSTALL>","2", TRUE );
What are the difference between these two?
How to display a property in a message box?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hello Jenifer,
I have two Directories defined in the Directory table: MY_INSTALL_DIR1, MY_INSTALL_DIR2.
Based on the condition, I want to set MY_INSTALL_DIR1 to be MY_INSTALL_DIR2. I cannot hard code the MY_INSTALL_DIR2 because it is a sub folder under /Program Files.
I tried the following two ways but neither worked:
Option 1) TextSubSetValue("<MY_INSTALL_DIR1>","<MY_INSTALL_DIR2>", TRUE );
Option 2) MsiGetProperty(ISMSI_HANDLE, "MY_INSTALL_DIR2", szValueBuf4, cchValueBuf);
MsiSetProperty(ISMSI_HANDLE, "MY_INSTALL_DIR1", szValueBuf4);
How to really set MY_INSTALL_DIR1 to be MY_INSTALL_DIR2 in InstallScript?
What is the relationship between Property object and Directory object? How to assign a Directory value to a Property?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @AceBear ,
How about saving those values in property itself and making use of function FeatureSetTarget by following guidelines in the below article:
- Create two custom folders as mentioned in above article
- Try setting public properties based on your need
- Get property and set it to custom directory that you had created before
Sample code would be:
MsiGetProperty (ISMSI_HANDLE , "dirproperty", svPropName, nSize);
FeatureSetTarget ( MEDIA , "MY_CUSTOM_PATH" , svPropName );
Thanks,
Jenifer
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)