Inno Setup-将用户文件放入管理文档中 [英] Inno Setup - puts user files in admin documents

查看:51
本文介绍了Inno Setup-将用户文件放入管理文档中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个Windows 7用户,他们在安装并自己登录时要求提供Admin密码.发生这种情况时,Inno Setup会为该用户安装程序,但会将示例数据文件放置在Admin的documents文件夹中.

I have a few Windows 7 users who, when installing and logged in as themselves, are asked to provide the Admin password. When this happens, Inno Setup installs the program for that user but it places the sample data files in the Admin's documents folder.

如何确保Inno Setup将样本数据文件放置在用户所属的文档文件夹中?

What can I do to make sure Inno Setup places the sample data files in the user's Documents folder where they belong?

[Files]
Source: "C:\dev\Installer Files\Chess Openings Wizard 2016\Game Trees\*.*";   DestDir: "{code:GetDataDir}\Game Trees";   Flags: uninsneveruninstall recursesubdirs

function GetDataDir(Param: String): String;
begin
  { Return the selected DataDir }
  Result := DataDirPage.Values[0];
end;

推荐答案

您的方法不正确.

有两种正确的方法:

  1. 如果安装程序仅为当前(非特权)用户安装应用程序,则不需要管理员权限.

  1. If the installer installs the application for the current (unprivileged) user only, do not require Administrator privileges.

PrivilegesRequired=lowest

然后 {userappdata}常量(以及类似内容) )将正确引用当前用户的文件夹.

Then the {userappdata} constant (and similar) will correctly refer to the current user's folder.

如果安装程序为所有用户安装了该应用程序,则将某些文件放入一个特定用户的文件夹中没有意义.所有用户都需要文件,而不仅仅是一个.在这种情况下,建议的方法是使用

If the installer installs the application for all users, it does not make sense to put some files to folder of one specific users. All users need the files, not just the one. In this case the recommended approach is to install the files to "Common" folder, using the {commonappdata} constant (or similar). And have the application copy the files to the user folder on the first run.

另请参见如何在用户使用以管理员身份运行"时使用安装程序写入用户的我的文档"目录.

您还可以允许用户在这两种方法之间进行选择.
请参见仅在需要时使Inno Setup安装程序请求特权提升.

You can also allow the user choose between these two approaches.
See Make Inno Setup installer request privileges elevation only when needed.

有关其他类似问题,请参见

For another similar questions, see

  • Inno Setup Using {localappdata} for logged in user
  • Inno Setup always installs into admin's AppData directory

话虽如此,您可以通过执行外部复制实用程序( copy xcopy ExecAsOriginalUser函数 >(或 runasoriginaluser标志 >部分).

Having that said, you can do, what you ask for, by executing an external copy utility (copy, xcopy, robocopy) using the ExecAsOriginalUser function (or the runasoriginaluser flag in the [Run] section).

ExecAsOriginalUser(
  'cmd.exe', '/c xcopy.exe "sourcefile" "%APPDATA%"',
  '', SW_HIDE, ewWaitUntilTerminated, ResultCode);

有关此方法的更多详细信息,请参见类似的问题 Inno Setup为登录用户(非admin用户)创建注册表项.

For more detail on this approach, see a similar question Inno Setup Creating registry key for logged in user (not admin user).

这篇关于Inno Setup-将用户文件放入管理文档中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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