Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

wix3 - Wix - change the installation folder based on privilege

I have to create an installation package using Wix. If an admin user is installing the package, it should install into %programfiles%/[applicationName], if the user is an non-admin user then it should install into its local profile folder( LocalAppDataFolder).

How it is possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I wrote this for ClickThrough a long time ago. Solution from that looks a lot like this (You provide a Property called "ApplicationFolderName"):

    <Property Id="A" Secure="yes" />

    <DirectoryRef Id="TARGETDIR">
        <Directory Id="ApplicationFolder" Name="App" />
    </DirectoryRef>

    <Condition Message="Must specify TARGETDIR property when doing an administrative install.">Installed OR (ACTION="ADMIN" AND TARGETDIR&lt;&gt;"")</Condition>

    <CustomAction Id="TARGETDIRtoA" Property="A" Value="[TARGETDIR]" Execute="firstSequence" />

    <CustomAction Id="SpecifiedA" Property="ApplicationFolder" Value="[A]" Execute="immediate" />
    <CustomAction Id="PerMachineInstall" Property="ApplicationFolder" Value="[ProgramFilesFolder][ApplicationFolderName]" Execute="immediate" />
    <CustomAction Id="PerUserInstall" Property="ApplicationFolder" Value="[LocalAppDataFolder]Apps[ApplicationFolderName]" Execute="immediate" />

    <InstallUISequence>
        <Custom Action="SpecifiedA" Before="LaunchConditions">NOT Installed</Custom>
    </InstallUISequence>

    <InstallExecuteSequence>
        <Custom Action="PerMachineInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
        <Custom Action="PerUserInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged))</Custom>
    </InstallExecuteSequence>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...