Inno Setup AfterInstall procedure is executed too early, when installing MSI from Run section with /qn (silent) switch

走远了吗. 提交于 2021-01-24 09:41:47

问题


After the execution of the mariadb-10.2.11-winx64.msi file, that installs the MariaDB 10.2.11 Server, I would like to make some changes on the my.ini file of the MariaDB 10.2.11 Server after it has been installed.

I have tried to use the AfterInstall parameter as shown bellow:


[Files]
Source: C:\Setup\Bin\mariadb-10.2.11-winx64.msi; DestDir: {tmp}; \
    Flags: ignoreversion promptifolder deleteafterinstall; Components: server

[Run]
Filename: {tmp}\mariadb-10.2.11-winx64.msi; Parameters: /qn; \
    WorkingDir: {tmp}; Flags: shellexec waituntilterminated; AfterInstall: ConfigMyIni
[Code]

procedure ConfigMyIni;
var
  MyIni : String;
begin
  MyIni := ExpandConstant('{pf}\MariaDB 10.2\data\my.ini');
  if FileExists(MyIni) then
    begin
      if IniKeyExists('mysqld', 'character-set-server', MyIni) then
        SetIniString('mysqld', 'character-set-server', 'uft8', MyIni)
      else
        SetIniString('mysqld', 'character-set-server', 'uft8', MyIni);

      if IniKeyExists('mysqld', 'collation-server', MyIni) then
        SetIniString('mysqld', 'collation-server', 'uft8_bin', MyIni)
      else
        SetIniString('mysqld', 'collation-server', 'uft8_bin', MyIni);

      if IniKeyExists('mysqld', 'lower-case-table-names', MyIni) then
        SetIniString('mysqld', 'lower-case-table-names', '1', MyIni)
      else
        SetIniString('mysqld', 'lower-case-table-names', '1', MyIni);
    end;
end;

I have stepped through the script code and I have found that the ConfigMyIni procedure is executed before the end of the execution of the mariadb-10.2.11-winx64.msi file. The my.ini file does not exist at that moment. How can I force the ConfigMyIni procedure to be executed only after the end of the execution of the mariadb-10.2.11-winx64.msi file?

I have already read the help of Inno Setup and have searched for any answer on Stack Overflow but have not found any clue that I could follow to solve my problem.

Could anyone give some help on this problem?


回答1:


That is a consequence of the /qn switch. With the switch, the top-level msiexec process delegates installation to a hidden subprocess and terminates itself immediately.

Consider using /qb or /qb! or similar, instead.

See msiexec command-line options.



来源:https://stackoverflow.com/questions/47739100/inno-setup-afterinstall-procedure-is-executed-too-early-when-installing-msi-fro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!