2

I have created a silent installer Using WIX for my application. I want it to install my application to C:\MyApps folder but its Directory Id='TARGETDIR' Name='SourceDir' tag randomly picks C or D drive. I want to enforce my installation to C drive only. Also in case, I provide version number greater than 4.0.5, I am geting an error during installation saying "This installation package cannot be installed by the Windows Installer Service. You must install a newer version of the Window Installer service." I am having Windows XP professional SP3 Version 2002.

Singla Amit
  • 37
  • 2
  • 8
  • Can you please pot the code that defines your product version. It sounds to me like you're defining the *Windows Installer* version instead of your product's version. – Hand-E-Food Feb 22 '12 at 22:03
  • 1
    My product & package tags look like ` ................` – Singla Amit Feb 23 '12 at 04:41

4 Answers4

4

To begin with, I think you should start your WiX journey with the tutorial available here. It contains the answers to the most of basic questions you'll face with the first thing. You should also be aware that understanding WiX means understanding the concepts of Windows Installer first - otherwise some points will seem a weird magic to you.

When you create a new WiX setup project in Visual Studio, it generates a template with some placeholders. It is recommended to start modifying this template. For instance, the directory structure:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLLOCATION" Name="SetupProject1">
      <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
      <!-- <Component Id="ProductComponent" Guid="ba7d579f-5234-4448-b880-109f589d58e5"> -->
      <!-- TODO: Insert files, registry keys, and other resources here. -->
      <!-- </Component> -->
    </Directory>
  </Directory>
</Directory>

This snippet defines the INSTALLLOCATION folder under the ProgramFileFolder, and this is a better approach than to place it under the C:\ root. You can still change the installation location by modifying the INSTALLLOCATION property at install time (for instance, base on user's input).

The quick answer to your questions are:

...randomly picks C or D drive...

That's expected - it picks the drive with the most free space by the time of installation. If you stick to the way WiX template defines by default, it will fall under C: (actually, under Program Files folder).

...You must install a newer version of the Window Installer service...

Basically, it means what it says - the version Windows Installer on your machine is lower than the one you require in your package. If you try to solve the above problems with this change, then it has nothing to do with the Windows Installer version. You should require higher version than it is specified by default only in case you are going to use new features of Windows Installer.

Hope you'll make right conclusion out of this brief intro - start with the tutorial. :-)

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • Actually it's a client demand to install at c:\MyApps directory and not under program files also installer must be a silent one so no user input I can have to set install directory location. I want to avoid to enforce all users to update their Windows installer package. Also having everything else same but changing version number to 4.0.6 or higher demands for newer version of installer package. In case am providing version number to be 4.0.5 or lesser ,Application is getting installed smoothly. I have gone through tutorial and various blogs but can't find much help. Many thanks in advance... – Singla Amit Feb 22 '12 at 11:18
2

Try this:

<Fragment>
    <Property Id="_BrowseProperty" Value="INSTALLDIR" Secure="yes"/>
    <CustomAction Id="SetDataLocationDefault" Property="INSTALLDIR" Value="[WindowsVolume]$(var.Title)\" />
    <InstallUISequence>
      <Custom Action="SetDataLocationDefault" After="CostFinalize" />
    </InstallUISequence>
    <InstallExecuteSequence>
      <Custom Action="SetDataLocationDefault" After="CostFinalize" />
    </InstallExecuteSequence>    
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="INSTALLDIR" Name="$(var.Title)">
     <!-- TODO: Insert your components here. -->
      </Directory>
    </Directory>

  </Fragment>

I think this should work!

Bio42
  • 389
  • 3
  • 18
2

The problem with your versions is you're changing the Windows Installer version when you change your Product version.

<Package
    Id='*' 
    InstallerVersion='406'
    Compressed='yes'
    Description="Installer Number 406" />

The InstallerVersion attribute should be the minimum required version of Windows Installer required to install this package. You have Windows Installer v4.5 installed. When this is set to 406, it looks for Windows Installer v4.6 which frankly, doesn't exist. Setting this to 301 (version 3.1) is usually sufficient.

    InstallerVersion='301'

While your description attribute is fine, I would find the following more meaningful:

    Description="My Product v4.0.6 Installer"
Hand-E-Food
  • 12,368
  • 8
  • 45
  • 80
0

Do not rely on TARGETDIR, and use the custom property, like this:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLLOCATION" Name="SetupProject1">
      <!-- TODO: Insert your components here. -->
  </Directory>
</Directory>

The template is taken from Yan's answer. Set INSTALLLOCATION to the desired folder C:\MyApps, that should do the trick.

Community
  • 1
  • 1
Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68