安装mysql(在安装程序上)同时安装另一个应用程序(inno setup)

时间:2015-09-30 09:01:37

标签: mysql windows installer inno-setup

我正在尝试为我的应用程序创建一个安装程序。我选择使用InnoSetup。我成功创建了一个简单的安装程序,但对于我的应用程序,我必须同时安装mysql(启动服务并创建数据库)。 我已经看到我已经将“.msi”添加到项目的文件中。我已经得到了代码示例,但我有一个错误,我不明白。我不熟悉在Windows中注册。 当我使用此代码时,我没有“HKEY_LOCAL_MACHINE / SOFTWARE”上的文件夹“MYSQL AB”,如果我通过点击我的.msi进行安装,安装有效,但我在“HKEY_LOCAL_MACHINE / SOFTWARE”上没有“MYSQL AB”文件夹”。也许这个版本的代码还没有用。     [文件]     来源:“Path \ to \ Appli.exe”; DestDir:“{app}”;标志:ignoreversion     来源:“Path \ to \ my.dll”; DestDir:“{app}”;标志:ignoreversion     来源:“Path \ to \ mysql-5.5.45.0.msi”; Destdir:“{tmp}”;标志:nocompression dontcopy

[Icons]
...

[Run]
Filename: "{reg:HKLM\SOFTWARE\MySQL AB\MySQL Server 5.5,Location}\bin\mysqld.exe"; Parameters: "--install"; WorkingDir: "{reg:HKLM\SOFTWARE\MySQL AB\MySQL Server 5.5,Location\bin}"; StatusMsg: "Installing MySQL Service"; Description: "Installing MySQL Service"; Flags: runhidden; Check: MySQL_Is

[Code]
function MySQL_Is(): Boolean;
var
iResultCode: Integer;
begin
  Result := true;
  if (not RegKeyExists(HKLM, 'SOFTWARE\MySQL AB\MySQL Server 5.5')) or 
   (not FileExists(ExpandConstant('{reg:HKLM\SOFTWARE\MySQL AB\MySQL Server 5.5,Location}\bin\mysql.exe'))) 
  then begin
     ExtractTemporaryFile('mysql-5.5.45.0.msi');
     Exec('msiexec.exe', '/i mysql-5.5.45.0.msi /qn INSTALLDIR="C:\Program Files\mySQL"', 
      ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, iResultCode);
         if not FileExists(ExpandConstant('{reg:HKLM\SOFTWARE\MySQL AB\MySQL Server 5.5,Location}\bin\mysql.exe')) then begin
            MsgBox('Something went wrong! Installation should be terminated', 
              mbInformation, MB_OK);
            Result := false;
         end;
  end;
end;

我尝试过使用mysql-5.5.45.0.msi和mysql-5.6.26.0.msi,我遇到了同样的问题。

这是编译器输出:

[10:53:08,966]   *** Setup started
[10:53:09,762]   Setup version: Inno Setup version 5.5.6 (a)
[10:53:09,762]   ...
[10:53:14,708]   -- File entry --
[10:53:14,708]   Dest filename: C:\Program Files (x86)\My App with BDD\unins000.exe
[10:53:14,754]   Time stamp of our file: 2015-09-30 10:53:09.450
[10:53:14,754]   Installing the file.
[10:53:14,754]   Uninstaller requires administrator: Yes
[10:53:14,770]   Successfully installed the file.
[10:53:14,770]   -- File entry --
[10:53:14,786]   Dest filename: C:\Program Files (x86)\My App with BDD\App.exe
[10:53:14,786]   Time stamp of our file: 2015-09-28 14:06:26.000
[10:53:14,786]   Installing the file.
[10:53:14,801]   Successfully installed the file.
[10:53:14,801]   -- File entry --
[10:53:14,801]   Dest filename: C:\Program Files (x86)\My App with BDD\my.dll
[10:53:14,817]   Time stamp of our file: 2013-04-22 18:03:56.000
[10:53:14,817]   Installing the file.
[10:53:16,268]   Successfully installed the file.
[10:53:16,268]   -- File entry --
[10:53:25,512]   ...
[10:53:25,559]   -- Icon entry --
[10:53:25,559]   Dest filename: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My App with BDD\My App with BDD.lnk
[10:53:25,574]   Creating directory: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My App with BDD
[10:53:25,574]   Creating the icon.
[10:53:25,746]   Successfully created the icon.
[10:53:25,761]   -- Icon entry --
[10:53:25,761]   Dest filename: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My App with BDD\Uninstall My App with BDD.lnk
[10:53:25,761]   Creating the icon.
[10:53:25,777]   Successfully created the icon.
[10:53:25,949]   Installation process succeeded.
[10:53:25,980]   Extracting temporary file: C:\Users\4MODES~1\AppData\Local\Temp\is-P8CQH.tmp\mysql-5.5.45.0.msi
[10:54:18,145]   Message box (OK):
    Something went wrong! Installation should be terminated

msi的提取似乎没问题(在C:\ Program Files(x86)上有MySQL文件夹)但我没有在“C:\ Program Files”上找到MySQL文件夹。在注册表中,我在“HKEY_LOCAL_MACHINE / SOFTWARE”上看不到文件夹“MySQL AB”

感谢您的帮助

0 个答案:

没有答案