【问题标题】:How to tell a setup file to install to the Documents folder with Inno Setup compiler?如何使用 Inno Setup 编译器告诉安装文件安装到 Documents 文件夹?
【发布时间】:2017-11-08 19:18:03
【问题描述】:

我正在尝试使用 Inno Setup Compiler 创建一个安装文件,并且我希望它安装到 Documents 文件夹中,因为它需要创建然后删除一个文件,如果它安装到 Program 则无法执行此操作文件。我试过使用%userprofile%\Documents,因为它在文件资源管理器中工作,但这只是在Setup.exe 所在的地方创建一个名为%userprofile% 的文件夹,C:\Users\%username%\Documents 只是在用户文件夹中创建%username% 文件夹。无论它在哪里,如何让它安装到 Documents 文件夹中?

【问题讨论】:

  • 不要安装到文件夹中。像您应该的那样安装到程序文件。如果您的程序需要创建和删除非文档数据文件,请将它们存储在 Application Data 文件夹中。您的开发工具应提供一种在运行时发现该位置的方法。

标签: installation inno-setup


【解决方案1】:

虽然@GTAVLover 是对的,您很可能希望在标准 Inno 设置部分中使用 {userdocs} or {commondocs} constant,例如 [Files]

语法如下:

[Files]
Source: "readme.txt"; DestDir: "{userdocs}"

如果您想引用环境变量(在这种情况下不正确的方法),请使用{%NAME} 语法:

[Files]
Source: "readme.txt"; DestDir: "{%USERPROFILE}\Documents"

【讨论】:

    【解决方案2】:

    您应该使用 Inno Setup Shell 文件夹常量来执行此操作。

    Inno Setup Help.查看更多信息

    使用ExpandConstant('{userdocs}') 获取文档文件夹的路径(对于当前用户)。

    它将返回"OS Drive:\Users\CurrentUser\Documents"

    例如:

    MsgBox(ExpandConstant('{userdocs}'), mbInformation, MB_OK);
    

    对于所有用户,您应该将userdocs 替换为commondocs

    所以,它会返回"OS Drive:\Users\Public\Documents"

    【讨论】:

      猜你喜欢
      • 2013-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-17
      • 1970-01-01
      • 2017-01-08
      相关资源
      最近更新 更多