Wix - 根据权限更改安装文件夹

发布于 2024-07-24 22:33:23 字数 149 浏览 5 评论 0原文

我必须使用 Wix 创建一个安装包。 如果管理员用户正在安装软件包,则应安装到%programfiles%/ [applicationName]中,如果用户是非管理员用户,则应安装到其本地配置文件文件夹(LocalAppDataFolder)中。

怎么可能呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

锦欢 2024-07-31 22:33:23

很久以前,我为 ClickThrough 写了这篇文章。 解决方案看起来很像这样(您提供一个名为“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<>"")</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>

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<>"")</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>
婴鹅 2024-07-31 22:33:23

重写 ProgramFilesFolder 属性如下所示应该有效:

<SetProperty Id="ProgramFilesFolder" Value="[AppDataFolder]" Before="CostFinalize"><![CDATA[ NOT Privileged]]></SetProperty>

<Directory Id="ProgramFilesFolder" Name="PFiles">
    <Directory Id="INSTALLDIR" Name="My Folder">
        ...
    </Directory>
</Directory>

Overriding ProgramFilesFolder property as following should work:

<SetProperty Id="ProgramFilesFolder" Value="[AppDataFolder]" Before="CostFinalize"><![CDATA[ NOT Privileged]]></SetProperty>

<Directory Id="ProgramFilesFolder" Name="PFiles">
    <Directory Id="INSTALLDIR" Name="My Folder">
        ...
    </Directory>
</Directory>
耶耶耶 2024-07-31 22:33:23

设置属性所有用户 2. 另请参阅单一包创作

Set property ALLUSERS to 2. See also Single Package Authoring.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文