Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have a web setup project. I need to check whether IIS is configured on target machine before installation. I have used the following URL, IIS Launch Condition[^] , But this is not working if the target machine is Windows 7 . Can anyone help me to solve this?

Update : This issue is with 64 bit OS only.

Now I can check the presence of IIS by reading registry key. Here is the code for that.

C#
private bool showError = false;
public bool ShowError
  {
    get { return showError; }
    set { showError = value; }
  }

private string subKey = @"SOFTWARE\Wow6432Node\Microsoft\Inetmgr\Parameters";
public string SubKey
  {
     get { return subKey; }
     set { subKey = value; }
  }

private RegistryKey baseRegistryKey = Registry.LocalMachine;
public RegistryKey BaseRegistryKey
        {
            get { return baseRegistryKey; }
            set { baseRegistryKey = value; }
        }

C#
private void ShowErrorMessage(Exception e, string Title)
 {
    if (showError == true)
      MessageBox.Show(e.Message,Title,MessageBoxButtons.OK, MessageBoxIcon.Error);
  }

C#
   public string Read(string KeyName)
   {
       RegistryKey rk = baseRegistryKey;
       // Open a subKey as read only
       RegistryKey sk1 = rk.OpenSubKey(subKey);
       // If the RegistrySubKey doesn't exist -> (null)
       if (sk1 == null)
       {
           return null;
       }
       else
       {
           try
           {
               // If the RegistryKey exists I get its value or null is returned.
               return (string)sk1.GetValue(KeyName.ToUpper()).ToString();
           }
           catch (Exception e)
           {
               ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
               return null;
           }
       }
   }

private void button2_Click(object sender, EventArgs e)
   {
      MessageBox.Show(Read(@"MajorVersion"));
   }


But in my web setup project, the Launch condition is not working.
I have tried it as follows....
C#
Name    = Search for IIS
Propery = IISVERSION
regKey  = HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Inetmgr\Parameters
Root    = vsdrrHKLM
Value   = MajorVersion


I have given the condition as follows....

C#
IISVERSION >= "#4"


But this condition is not seems to be working. When I tried it in a 64 bit Windows 7 machine with IIS configured, the installer failed with IIS launch condition.

Any help on this would be appreciated.

Regards
Sebastian
Posted
Updated 29-Jun-12 2:33am
v5
Comments
Sebastian T Xavier 2-Jul-12 2:11am    
This issue is not yet solved; If anyone knows the solution please update, thanks

1 solution

Does this not help: Right-click web setup project -> View -> Launch Condition -> IIS Condition to set for IIS check.


UPDATE:
There is an alternative that can be used. We are told that which registry key needs to be checked for IIS here: http://learn.iis.net/page.aspx/135/discover-installed-components/[^].
Your launch condition can read that specific registry key (HKLM\SOFTWARE\Microsoft\InetStp\Components\Metabase) and check if the value equals the string "1".

This post[^] sounds user was successful in it with Win7.

Worth a try!
 
Share this answer
 
v2
Comments
Sebastian T Xavier 27-Jun-12 1:07am    
Thank you Sandeep. This is what I have tried earlier. This is working fine in windows xp but in Windows 7, it's not working as expected. I hope you have seen the URL in my post.
Sandeep Mewara 27-Jun-12 2:04am    
Ok. I did looked at your link but to me it looked a little different setting/way to have IIS check.

Will share if I come across anything else.
Sebastian T Xavier 27-Jun-12 2:13am    
Thank you Sandeep
Sandeep Mewara 27-Jun-12 2:58am    
Updated my answer with an alternative that I came across.
Sebastian T Xavier 28-Jun-12 6:44am    
Thanks Sandeep, for your update. At last I have figured out the exact problem. The above registry key read will not work with 64 Bit OS. I have confirmed this with a 32 bit Windows 7 OS.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900