79106794

Date: 2024-10-20 10:15:28
Score: 0.5
Natty:
Report link

I wanted to thank everyone who helped me find a solution. The original problem was to deploy my C# application together with a firebirdsql instance as a service (and connect to it) installing everything from a single file and single click. I ended up using InnoSetup (which I had never used). I of course added all the application ddl + my firebird.FDB database and the Firebird installation file Firebird-5.0.1.1469-0-windows-x64.exe. The setup first installs only my C# application in which the Setup procedure starts the Firebird .exe file and connects the database that I find in the app's installation dir. Before installing, I check that there is no Firebird already installed.

This is the code to check if there is an active firebird service

foreach (ServiceController s in ServiceController.GetServices())
    {
        if (UCase(Strings.Mid(s.ServiceName, 1, 8)) == "FIREBIRD") // AndAlso s.Status = ServiceControllerStatus.Running
        {
            switch (s.Status)
            {
                case 4: // ServiceControllerStatus.Running
                    {
                       // to do something
                    }
                case 1: // ServiceControllerStatus.Paused
                    {
                        // to do something
                    }
            }
        }
    }

This is the code to silently install Firebird as Service:

 string appPath = Path.GetDirectoryName(Application.ExecutablePath);
    string exedinstall = "Firebird-5.0.1.1469-0-windows-x64.exe";
    string installFile = appPath + @"\" + exedinstall;
    string Arguments = @"/SP- /SILENT /SUPPRESSMSGBOXES /NOCANCEL  /NORESTART/MERGETASKS='UseSuperServerTask\CopyFbClientAsGds32Task'/SYSDBAPASSWORD='masterkey'/FORCE";     
    var installerProcess = new Process();
    installerProcess.StartInfo.CreateNoWindow = true;
    installerProcess.StartInfo.RedirectStandardOutput = true;
    installerProcess = Process.Start(installFile, Arguments);

    while (installerProcess.HasExited == false)
    {
        // indicate progress to user 
        Application.DoEvents();
        System.Threading.Thread.Sleep(250);
    }

I am not a professional and there may be some formal errors, but I will be very happy if this code can help someone. Thanks again everyone

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: L.Andrea