title: Install MySQL service in Inno Setup
body: <p>I would like to install MySQL service after install in <code>Inno Setup</code>. There is already similar question <a href="https://stackoverflow.com/questions/15204587/how-to-install-a-windows-service-with-inno-setup" title="here">here</a>, but no solution there works for me.</p>
  
  <p>If I use <code>sc create</code> like that in the solution, then after installation command promt just pop up, but doesn't do anything.</p>
  
  <p>I tried modify command according some page, it works great in cmd:</p>
  
  <pre><code>sc create "MySQLSW" binpath= "\"C:\Program Files (x86)\Drevarska spolecnost\MySQL Server 5.6\bin\mysqld\" --defaults-file=\"C:\Program Files (x86)\Drevarska spolecnost\my.ini\" MySQLSW" DisplayName= "MySQLSW" start= "auto"
  </code></pre>
  
  <p>For Inno Setup it needs to be double quoted, so I tried this and few variants of it</p>
  
  <pre><code>[Run] 
  Filename: "{cmd}"; Parameters: "sc create ""MySQLSW"" binpath= ""\""{app}\MySQL Server 5.6\bin\mysqld\"" --defaults-file=\""{app}\my.ini\"" MySQLSW"" DisplayName= ""MySQLSW"" start= ""auto""";
  </code></pre>
  
  <p>But cmd won't execute anything. Problem could be with that backslash, but I don't know the correct syntax.</p>
  
  <p>I also tried add API from <a href="https://github.com/pgina/pgina/blob/master/Installer/scripts/services.iss" rel="nofollow noreferrer" title="here">here</a> and use following code, but there must be something wrong too, because it just pass installation, but won't create service.</p>
  
  <pre><code>procedure CurStepChanged(CurStep: TSetupStep);
  begin
  if CurStep = ssPostInstall then
    begin
      if IsServiceInstalled('MySQLSW') = false then begin
        if InstallService(ExpandConstant('{app}\MySQL Server 5.6\bin\mysqld.exe'),ExpandConstant('--defaults-file="{app}\my.ini"'),'MySQLSW','Needed for mysql database',SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START) = true then begin
          StartService('MySQLSW');
        end
      end
      else if IsServiceRunning('MySQLSW') then
          MsgBox('MySQLSW is running',mbInformation, MB_OK);
    end;
  end;
  </code></pre>
  
  <p>I'm not much skilled in this yet, but I'm sure, there would be some misplaced quote somewhere, but I can't find it. Thanks in advance for help.</p>