繁体   English   中英

Inno Setup - 更改目录权限不会不时影响

[英]Inno Setup - Change directory permission not affect time to time

我有安装在C://ProgramFiles 中的应用程序。 我需要用户组的安装目录完全访问权限来处理应用程序的更新过程(文件下载、移动、删除、写入)。 所以我更新 inno-script 如下。

[InstallDelete]
Type: filesandordirs; Name: "{app}\assets"; BeforeInstall: TaskKill()

[Dirs]
Name: "{app}\assets"; Permissions: users-full; Flags: uninsalwaysuninstall;

[Files]
; Change file path when necessary
; Service, Launcher, Killer, runtime Binaries
Source: "..\..\_Source\Bin\*"; DestDir: "{app}"; Flags: recursesubdirs ignoreversion;

_Source\\Bin文件夹(包含所有文件的源文件夹)中有一些文件和 assert 文件夹。

问题是,安装没有不时更改用户组的断言文件夹权限 (大多数时候工作正常)。 这是有问题和没有问题的两个日志的比较。

安装程序日志比较有问题和没有问题

请给出任何想法或任何可能性来克服这个问题。

在参考安装程序的日志后,我发现文件复制时重新创建了授予权限的文件夹。

所以我决定通过在安装程序之后执行 windows icacls命令来设置用户权限。 所以我像下面那样更改了脚本,然后按预期工作。

// Following method will execute to grant user permisions after installation //
procedure PermissionUpdate();
var
  ResultCode: integer;
begin
  Log(ExpandConstant('Giving user group permission :O - CODE: - ' + ExpandConstant('"{app}/assets" /grant *S-1-5-32-545:(OI)(CI)M /t /c /q')));
  
  if Exec('icacls.exe', ExpandConstant('"{app}/assets" /grant *S-1-5-32-545:(OI)(CI)M /t /c /q'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
  begin
    Log('Successfully gave user group permission :)' + IntToStr(ResultCode));
  end
  else begin
    Log('Giving user group permission unsuccessfull :('  + IntToStr(ResultCode));
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if (CurStep=ssInstall) then
  begin
    if (IsUpgrade()) then
    begin
      UnInstallOldVersion();
    end;
  end
  else if (CurStep=ssPostInstall) then
  begin
    PermissionUpdate();
  end;
end;

所以在这个修复中CurStepChanged方法是安装程序的事件处理程序。 我使用安装后步骤( CurStep=ssPostInstall )来运行权限更新方法。 在执行icacls方法时, S-1-5-32-545是用户组的安全标识符

这可能不是我发布的解决方案,但此修复程序对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM