6

I have an Windows Installer for my application. Application package also contains Installer class where some of the actions are performed other are performed in Custom Actions.

The Installer installs another application from Custom Actions during Install. I want to know if this application already exists of same version I don't want to install or provide a Messagebox asknig to Reinstall Y/N.

If my application is already installed, and I click the same installer again, I get "Repair" and "Remove" options. But if the installer is newly built, I get a dialog stating "Another version is already installed ... remove using Add Remove Programs..". So I can't update the exisitng version without uninstallng it. How can I update the existing version ?

Any help or guidance for these 2 queries are highly appreciated. I looked on net for these but couldn't get apropriae answers. If you can help me, that would be really great.

CODE

prouct.xml

<?xml version="1.0" encoding="utf-8" ?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
 ProductCode="My.Bootstrapper.ABC">

 <!-- Create Package, Product Manifest http://msdn.microsoft.com/en-us/library/ee335702.aspx
  Schema Reference : http://msdn.microsoft.com/en-us/library/ms229223.aspx
   -->

 <PackageFiles>
     <PackageFile Name="XYZ.exe"/>
 </PackageFiles>

 <InstallChecks>
     <!-- If its installed, it will be in Uninstall. DisplayName will be XYZ2.1_rc22  
     Can still get values of DisplayVersion (2.1_rc22) & UninstallString from this key
     -->
    <RegistryCheck
       Property="IS_XYZ_INSTALLED"
       Key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XYZ"
       Value="DisplayName"/>
  </InstallChecks>

  <Commands>
     <Command PackageFile="XYZ.exe" Arguments="/Install">
     <InstallConditions>
         <BypassIf Property="IS_XYZ_INSTALLED" 
           Compare="ValueEqualTo" Value="XYZ2.1_rc22"/>    // tHIS IS THE DISPLAYNAME, THAT I SEE IN REGISTY
        <FailIf Property="AdminUser"
           Compare="ValueNotEqualTo" Value="True"
           String="NotAnAdmin"/>
     </InstallConditions>

     <ExitCodes>
       <ExitCode Value="0" Result="Success"/>
       <ExitCode Value="1641" Result="SuccessReboot"/>
       <ExitCode Value="3010" Result="SuccessReboot"/>
       <DefaultExitCode Result="Fail" String="GeneralFailure"/>
     </ExitCodes>
   </Command>
 </Commands>

</Product>

package.xml

<?xml version="1.0" encoding="utf-8" ?>
<Package  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
    Name="DisplayName" Culture="Culture">

 <!--Check for XYZversion 2.1_rc22 -->
 <Strings>
    <String Name="DisplayName">Install My XYZ</String>
    <String Name="Culture">en</String>
   <String Name="NotAnAdmin">Administrator permissions are required to install XYZ.Contact your 
              administrator.</String>
   <String Name="GeneralFailure">A general error has occurred while installing this   
          package.</String>
  </Strings>
</Package>

UPDATE : I want to install XYZ if it is not alerady installed on PC. With the Above code it doesn't install as Prerequisite. In Prerequisite I select my appication (along with Windows Installer 3.1 & .NET3.5) and have selected "Download prereq from same location as my appli". On Build of setup project, I get 3 folders in my Rel (for winIns, Net & my app o be installed as preq i.e. XYZ). Currently XYZ is not installed on my comp - so the key will not be found. When I install the installer, it installs the app but not the prereq i.e XYZ.exe application. Where am I going wrong ?

Thanks .

Tvd
  • 4,463
  • 18
  • 79
  • 125
  • How does it install the other application in the Custom Action, is it another MSI? – Jodrell Jun 06 '11 at 08:32
  • @Jodrell, the other application is a windows installer file. In Custom Action, I added that fiel under Install. Hence it executes while installation process and the exe file installs the other application – Tvd Jun 06 '11 at 13:25

2 Answers2

3

The Installer installs another application from Custom Actions during Install. I want to know if this application already exists of same version I don't want to install or provide a Messagebox asknig to Reinstall Y/N.

Instead of a custom action you should use a prerequisite. If you are using a Visual Studio setup project, perhaps this will help: Adding Custom prerequsites to visual studio setup project

If you are using another setup authoring tool, you should find out if it supports prerequisites or not.

If my application is already installed, and I click the same installer again, I get "Repair" and "Remove" options. But if the installer is newly built, I get a dialog stating "Another version is already installed ... remove using Add Remove Programs..". So I can't update the exisitng version without uninstallng it. How can I update the existing version ?

This happens because you modified the package without increasing the ProductVersion and modifying the ProductCode. If you want an automatic upgrade you need to modify them.

However, if you are just testing and you don't want to increase the ProductVersion, you need to manually uninstall the old package before installing the new one. This is how Windows Installer upgrades work.

Community
  • 1
  • 1
Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • @Cosmin, I can't make out how to use/configure bootstrap manifest with my app. I am using Windows Installer. My App name is "ABS.exe" and the other application that I am installing is "XYZ.exe" which is custom built by me. The system may have its original full version. The exe file name of my built app is same as the original full version exe file name. I recognize my built version by identifing file and folder names from the installed path. With this complex I can't make out how to use the custom Prerequsites. Can you please help me out. I think I am lost in all ths. – Tvd Jun 06 '11 at 13:16
  • @Cosmin, REG "Another version is already installed ...". Is there anyway to handle this. I mean can I give a custom message instead of the that system message. Can this be handled, if so How to handle this part ? – Tvd Jun 06 '11 at 13:27
  • I assumed that your other application has a different installer. In this case you can add the second installer as a prerequisite. If you are using a single package for both applications, why and how are you installing it from a custom action? Regarding the message, you cannot change it or handle it. Either you increase the version and change the Product Code or you manually uninstall the old version. – Cosmin Jun 06 '11 at 14:16
  • The other application has an Installer (exe file) though it is custom built by me and have prepared Installer as per my application needs. In Custom Actions, under Install, I have added that exe file from Application Folder. I just want to make sure that if the same version of other application is already installed my installer doesn't go to install it again. That's it. For this I got to use produst Manifest or Package Manifest ?? – Tvd Jun 06 '11 at 14:32
  • 1
    Yes, a prerequisite is installed only if it's not found. You can add your other installer as a prerequisite to your main package. – Cosmin Jun 06 '11 at 14:39
  • @Cosmin, Please have a look at the code added of product & package xml. As you can see I have added a RegistryCheck thru which I get value if the package ia alredy installed or not. In BypassIf I added if received value is not equal to the Value then install. This is what I want. I am not confident if I have coded correctly or not. I was wondering what if the Key of RegisterCheck is not found, then what will be the value of Property. You see the values received will be only String even the version that I get from DisplayVersion. How can I compare version with Lessthan greaterthan? Kindly help – Tvd Jun 07 '11 at 10:35
  • In have set my created Prerequisites to my installer. I hv .NET & Windows Installer already selected & "Download form venders site". I can see my bootstrapper & select it, but I got to install that from the application location itself & not vendor's site. When I tried to execute the installer after some time of "Preparing to install..." I get "Not Responding" and it fails. How to figure out the fault of "Not Responding". Pls have a look at the xml's to know it their is any mistake in xml or ???? – Tvd Jun 07 '11 at 11:50
  • You should use a public property (no lowercase letters) for your registry check, for example IS_XYZ_INSTALLED. Also, the BypassIf condition should be something like ValueEqualTo Value="the XYZ DisplayName value". This way the prerequisite is ignored if the IS_XYZ_INSTALLED property is set to the DisplayName value (the DisplayName entry was found). Regarding the "Not Responding" error, I'm not sure what it could be. Check if the prerequisite package works when launched directly. Also, make sure that it can be accessed by the setup package. – Cosmin Jun 07 '11 at 19:53
  • @Cosmin Thanks. But it still doesn't install - currently XYZ is not installed, hence the key will not be found. I tried with "ValueEqualTo" and "ValueNotEqualTo", but in any cases it doesn't install. I make changes in product.xml and copy to my bootstrapper package folder in MicrosoftSDKs. Rebuild my Setup project. I see the strapper folder in which exe file is there to install in my Release dir (as have selected download from app folder). I guess till here things are fine. Don't get "Not Responding" err also. Still wrong in cond I guess. What still missing? How to defien public Property ? – Tvd Jun 08 '11 at 08:25
  • CODE UPDATED AS YOU INSTRUCTED. – Tvd Jun 08 '11 at 08:25
  • The manifests seem ok. It's hard to tell why you are encountering this behavior when using them. You can try using the bootstrapper manifest generator to see if you can obtain a better manifest: http://archive.msdn.microsoft.com/bmg – Cosmin Jun 08 '11 at 10:33
  • I tried with BMG also referring http://jcrawfor74.wordpress.com/ site. I also tried with "Verion" instead of "DisplayName", but that also doen't work only. BMG compiles, its xml and my xml is same but somehow things doesn't work out only. – Tvd Jun 08 '11 at 11:28
0
  1. You can check the version of the executable files using GetFileVersionInfo and VerQueryValue WinAPI functions (there must be .Net counterparts).

  2. You can change ProductCode each time you generate MSI package. Upgrades must include the current version, i.e. you need to allow upgrades between the same version of the package, without changing the ProductVersion.

    Yet I would recommend following Cosmin's recommendation.


Update: answering to comment.

<Upgrade Id="Your-Upgrade-GUID">
  <UpgradeVersion Minimum="$(var.ProductVersion)"
                  IncludeMinimum="no"
                  OnlyDetect="yes"
                  Language="1033"
                  Property="NEWPRODUCTFOUND" />
  <!-- NEWPRODUCTFOUND property is set if a newer product version
       is installed. It is used to prevent downgrades. -->

  <UpgradeVersion Minimum="1.0.0"
                  IncludeMinimum="yes"
                  Maximum="$(var.ProductVersion)"
                  IncludeMaximum="yes"
                  Language="1033"
                  Property="UPGRADEFOUND" />
  <!-- UPGRADEFOUND property is set if older product version is installed
       or the same as the value of ProductVersion variable -->
</Upgrade>

We use the code above to perform upgrades even between the same version of the application. ProductVersion is a WiX preprocessor variable that contains the current version of the product. PackageCode is auto generated each build, using * as its value in .wsx file.

The key to make it work is IncludeMaximum="yes" attribute in the second UpgradeVersion element and the fact that each generated package has unique PackageCode.

Community
  • 1
  • 1
Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68
  • @Alexey, how can I handle Upgrading of my applciation. Do I have to change the Product Code or Version for Upgrading also ? And then if it is an upgrade, then the installed path should come auto ad not be allowed to change. How to get that in the installer ? I also have the Installer class. – Tvd Jun 06 '11 at 13:31
  • @Tvd, I've updated the answer providing WiX code snippet which makes it possible to upgrade current version installations without updating product version. – Alexey Ivanov Jun 07 '11 at 11:50
  • @alexey, Thanks. But I use Windows Installer using SEtu & Deployment using VS 2008. How to do the same with setup & deployment project. AS you recommend Cosmins' suggestion, can you please have a look at the code and my comments added under Cosmin's answer. OR How to handle the above with Setup & Deployment windows installer MSI. Would really appreciate. – Tvd Jun 07 '11 at 13:30
  • @Tvd Unfortunately I don't know how to do it with Setup & Deployment project. Bootstrappers look good to me. Perhaps it got the registry entries in Uninstall wrong. Or your prerequisite does not write any entries into the registry, does it? – Alexey Ivanov Jun 09 '11 at 06:19
  • @Alexey, how can I check the version of the executable and installed at time of Instalaltion in Custom Actions ? I got an idea to add a "SEarch Target Machine". Using the key, I get the Version in a property. But then how can I add that condition in Custom Actions - as I feel that Condition is for CustomActionData in CustomActions... – Tvd Jun 09 '11 at 11:12
  • Second IDEA, is their any way I can execute the other app .exe(installer generated via NSIS) in Installer Class. How and where do I look out for the file - by default it looks in /windows and not the folder where my application is ran from ??? – Tvd Jun 09 '11 at 11:14
  • @Tvd I know how to check the version of the executable using native WinAPI only. MSI may not provide an easy way to do it, however Searches may help here. Each Custom Action has a launch condition, and you can compare the detected version with the expected. The Custon Action will run when this condition evaluates to true. You can run any .exe from your code, or use a CA to start .exe file. Use the full path to the executable; you may need to evaluate it using the path to your running process. – Alexey Ivanov Jun 10 '11 at 08:15