简体   繁体   English

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

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

I have application which is installed in C://ProgramFiles .我有安装在C://ProgramFiles 中的应用程序。 I need installation directory full access to user group to handle update process of application (File download, move, delete, write).我需要用户组的安装目录完全访问权限来处理应用程序的更新过程(文件下载、移动、删除、写入)。 So I update inno-script as below.所以我更新 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;

In _Source\\Bin folder (Source folder which contained all files) there is some files and assert folder._Source\\Bin文件夹(包含所有文件的源文件夹)中有一些文件和 assert 文件夹。

The problem is, Installation did not change the assert folder permission time to time, for user group .问题是,安装没有不时更改用户组的断言文件夹权限 (Most of times work fine). (大多数时候工作正常)。 Here are comparison of two logs with and without issue.这是有问题和没有问题的两个日志的比较。

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

Please give any idea or any possibility overcome this issue.请给出任何想法或任何可能性来克服这个问题。

After referring the logs of installer, I found permission granted folder recreated when files copping.在参考安装程序的日志后,我发现文件复制时重新创建了授予权限的文件夹。

So I decided to set user permission by executing windows icacls command after installer process.所以我决定通过在安装程序之后执行 windows icacls命令来设置用户权限。 So I changed the script like below and after that work as expected.所以我像下面那样更改了脚本,然后按预期工作。

// 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;

So in this fix CurStepChanged method is event hander of the installer.所以在这个修复中CurStepChanged方法是安装程序的事件处理程序。 I use post install step ( CurStep=ssPostInstall ) to run permission update method.我使用安装后步骤( CurStep=ssPostInstall )来运行权限更新方法。 In executing icacls method, S-1-5-32-545 is security identifier for User Group.在执行icacls方法时, S-1-5-32-545是用户组的安全标识符

This may not the solution for which I posted but this fix worked for me.这可能不是我发布的解决方案,但此修复程序对我有用。

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

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