I have created a WiX installer MSI. When i run the msi, the installation path is asked for in the UI. Currently it loads the drive containing most of the free space. How can I set it to be at program files folder all the time? I tried the below line but it didn't work.
<Property Id="WIXUI_INSTALLDIR" Value="C:\\Program Files\" />
Below is the error I get for the above element.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2343. The arguments are: , ,
How can I make the UI load C:\Program Files as the default location all the time? Any help would be much appreciated.
You want to make use of the already defined windows installer properties which are always defined by Windows Installer (caveat on some 64-bit only properties). In this case specifically the ProgramFilesFolder
Try using a directory definition like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyProductFolder" />
</Directory>
</Directory>
</Fragment>
</Wix>
And then, following the same principal as this quick tutorial page about using WixUI_InstallDir
You'll want to do
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
Now when you show the UI page that lets you change the install location it should have the value C:\Program File\MyProductFolder
As a side-note, I would avoid making the install location just C:\Program Files because that may cause you to add a ton of extraneous files to this location where they should instead be contained in a product/program folder.
You should also never try to hardcode a path like "C:\Program Files\". In this specific case I can give you two quick examples why not to. There is no guarantee that the user is using the C:\ drive as their main drive or even uses a C:\ drive at all (one anecdote of this here). Another issue is (for 32-bit installs) on a 32-bit machine you'll want to install into the Program Files location but on a 64-bit machine you'll want to install into the "Program Files (x86)" location.