Problems installing the application through Windows Installer

I have a windows installer for my application. The application package also contains the Installer class, where some of the actions are performed, while others are executed in user actions.

The installer installs another application from the user actions during installation. I want to know if this application already exists in the same version. I do not want to install or provide Messagebox asknig to reinstall Y / N.

If my application is already installed, and I click the same installer again, I get the Repair and Uninstall options. But if the installer was recently built, I get a dialog box that says: "Another version is already installed ... uninstall using Add Remove Programs ..". Therefore, I cannot update the exisitng version without uninstalling it. How to upgrade an existing version?

Any help or guidance on these two queries is welcome. I looked at them, but could not get apropriae answers. If you can help me, that would be great.

THE 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 installed on the PC. If the code is above, it is not installed as a prerequisite. In preliminary order, I select my application (along with the Windows 3.1 and .NET3.5 installer) and select "Download prereq from the same place as my application." In the assembly of the installation project, I get 3 folders in my Rel (for winIns, Net and my application, o is installed as preq, that is, XYZ). XYZ is not currently installed on my computer, so the key will not be found. When I install the installer, it installs the application, but not the prieq ie XYZ.exe application. Where am I going wrong?

Thanks.

+6
source share
2 answers
  • You can check the version of executable files using GetFileVersionInfo and VerQueryValue WinAPI functions (must be .Net-copies).

  • You can modify the ProductCode every time you create an MSI package. Updates should include the current version, that is, you need to allow updates between the same version of the package without changing ProductVersion .

    However, I would recommend following the Cosmin recommendation .


Refresh : Reply to the 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 updates even between the same version of the application. ProductVersion is a WiX preprocessor variable that contains the current version of the product. Each assembly is automatically created by PackageCode , using * as its value in the .wsx file.

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

0
source

The installer installs another application from the user actions during Install. I want to know if an application already exists version I do not want to install or provide a Messagebox message for Reinstall Y / N.

Instead of a custom action, you should use a precondition. If you are using a Visual Studio installation project, this might help: Adding custom prerequsites to the visual studio setup project

If you are using another tool to create settings, you should find out if it supports the prerequisites or not.

If my application is already installed and I click the same installer again, I get Repair and Uninstall. But if the installer is newly built, I get a dialog indicating "Another version is already installed ... uninstall using Add Remove Programs ..". Therefore, I cannot update the exisitng version without uninstalling this. How to upgrade an existing version?

This is because you modified the package without increasing ProductVersion and changing ProductCode. If you want automatic updates, you need to change them.

However, if you are just testing and do not want to increase ProductVersion, you need to manually remove the old package before installing the new one. This is an update to Windows Installer.

+3
source

Source: https://habr.com/ru/post/889849/


All Articles