Question

I am using customized WiXUI_InstallDir UI for software installation. In browse dialog, we can choose even C:\ as installation directory. Is there any possible way that any time when user select C:\, it will automatically add a foldername also in it? e.g. If Software is XYZ software, then after browse to C:\ and press OK, it should show c:\XYZ in pathedit.

Was it helpful?

Solution

I've occasionally had customers ask for this over the year and I always tell them no. It's not a standard Windows Installer practice. Basically you are trying to prevent idiots from choosing a bad directory. This is practically impossible as there are many dumb places they can choose to put the software. If you really don't trust your users this much, take the choice away and always go to [ProgramFilesFolder]My Company\My Product.

OTHER TIPS

I tend to agree with Chris, take the choice away and go for standard installation directory. You may avoid all sorts of problems, and your software is more standards compliant.

The concept of changing the installation directory could be seen as an anti-pattern or a remnant of bad installer design from years ago when disk space was scarce and people installed all over the place. Software installations should be more standardized, and given the choice I lock the install to [ProgramFilesFolder]My Company\My Product like Chris suggests.

There are cases when you might want to allow the software to be installed on a memory stick or similar media. A better choice in these cases is to allow a special install that works straight off the stick - in other words it is a standalone application with no registry dependencies. Few application installers support this - the last one I saw was Opera some versions ago. Entirely different concept, but more meaningful than to allow non-standard installations by just changing the installation path.

Even though I agree that software should be installed under Program Files, I am writing a code that acts as you described. In this code, if the user selects C:\, it will be installed to C:\Program Files\XYZ. If another root folder is selected, it will be installed to, say D:\XYZ. You can extend this code further if you like.

Lets say you have a directory structure as

<Directory Id="TARGETDIR" Name="SOURCEDIR">
<Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLLOCATION" Name="XYZ" />
</Directory>
</Directory>

The code uses PathEdit UI control

<Control
Id="customPathEdit"
Type="PathEdit"
Property="TARGETDIR"
Fixed="Yes"
Remote="Yes"
X="10"
Y="10"
Width="100"
Height="17">

<Publish
    Property="INSTALLLOCATION"
    Value="[ProgramFilesFolder]XYZ\"
    Order="1"
    <![CDATA[TARGETDIR << %SYSTEMDRIVE]]>
</Publish>

<Publish
    Property="INSTALLLOCATION"
    Value="[TARGETDIR]XYZ\"
    Order="2"
    <![CDATA[NOT (TARGETDIR << %SYSTEMDRIVE)]]>
</Publish>


</Control>

Of course we need a PushButton control to alert the installer that path has changed:

<Control
Id="OkButton"
Type="PushButton"
Height="17"
Width="56"
x="50"
Y="70"
Text="OK">

    <Publish
    Event="SetTargetPath"
    Value="INSTALLLOCATION"
    Order="1">1</Publish>

            <!--Another publish element is required to go to the next dialog-->
</Control>

The first publish element sets the property INSTALLLOCATION to the path [ProgramFilesFolder]XYZ\ only if the user has selected %SYSTEMDRIVE. The second publish element is only used if the user has not chosen %SYSTEMDRIVE. The last publish element calls the SetTargetPath event to save the new install path to the installation session.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top