如何获取当前用户 %AppData% 文件夹? [英] How to get current user %AppData% folder?

查看:64
本文介绍了如何获取当前用户 %AppData% 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WIX,MSI 安装程序.

WIX, MSI-installer.

我在我的登录名是 developer 的某台计算机上构建了这个 MSI.在我的 MSI 中,我有这样的对话窗口:

I build this MSI on some computer where my login name is developer. In my MSI I have such dialog window:

但第三个变体总是包含 developer 用户名,即使当前用户有其他登录名...我该如何解决?

But third variant always contains developer user name even if current user has other login name... How can I fix it?

这是我的这些元素的代码:

This is my code of these elements:

<Control Id="rbgrPath" Type ="RadioButtonGroup"
         X="5" Y="80" Width="500" Height="100" Property="INSTALLFOLDER">
  <RadioButtonGroup Property="INSTALLFOLDER">
    <RadioButton
      Text="[$(var.PLATFORMPROGRAMFILESFOLDER)]Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Value="[$(var.PLATFORMPROGRAMFILESFOLDER)]Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Height="13" Width="500" X="5" Y="5"/>
    <RadioButton
      Text="$(env.ProgramData)\Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Value="$(env.ProgramData)\Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Height="13" Width="500" X="5" Y="20"/>
    <RadioButton
      Text="$(env.AppData)\Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Value="$(env.AppData)\Autodesk\ApplicationPlugins\ProxyTools.bundle\"
      Height="13" Width="500" X="5" Y="35"/>
  </RadioButtonGroup>
</Control>

UPD

这是PLATFORMPROGRAMFILESFOLDER变量定义:

推荐答案

这是因为在构建包时会评估 $(env.AppData) 和其他预处理器字符串.第二个单选按钮的值在碰巧使用 C: 以外的系统驱动器的机器上也是不正确的(或者在旧的——希望不受支持的——不使用 C:\ProgramData 的系统上).所以你应该使用运行时属性替换:

This is because $(env.AppData) and other preprocessor strings are evaluated when you build your package. The second radio button's value will also be incorrect on a machine that happens to use a system drive other than C: (or on older—hopefully unsupported—systems that don't use C:\ProgramData). So you should instead use run-time property substitutions:

  • $(env.ProgramData) 应替换为 [CommonAppDataFolder]
  • $(env.AppData) 应替换为 [AppDataFolder][LocalAppDataFolder]
  • 如果 [$(var.PLATFORMPROGRAMFILESFOLDER)] 没有解析为 [ProgramFilesFolder][ProgramFiles64Folder],它可能应该是改为这样做.
  • $(env.ProgramData) should be replaced with [CommonAppDataFolder]
  • $(env.AppData) should be replaced with either [AppDataFolder] or [LocalAppDataFolder]
  • If [$(var.PLATFORMPROGRAMFILESFOLDER)] doesn't resolve to [ProgramFilesFolder] or [ProgramFiles64Folder], it should probably be changed to do so.

请注意,可以使用其他目录属性来引用这些位置,只要您从上面引用的属性中设置它们的值即可.

Note that it's fine to use additional directory properties to refer to these locations, as long as you are setting their values from the properties referenced above.

这篇关于如何获取当前用户 %AppData% 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆