Imports System
Imports System.Configuration
Imports System.ServiceProcess
Imports System.Reflection

<System.ComponentModel.RunInstaller(True)> _
Public Class WinInstaller
    Inherits System.Configuration.Install.Installer

    Dim serviceInstaller As ServiceProcess.ServiceInstaller
    Dim serviceProcessInstaller As ServiceProcess.ServiceProcessInstaller

    Sub New()
        InitializeComponent()

        Me.Installers.Add(GetServiceInstaller)
        Me.Installers.Add(GetServiceProcessInstaller)
    End Sub

    Private Function GetServiceProcessInstaller() As ServiceProcessInstaller
        Dim _installer As New ServiceProcessInstaller

        _installer.Account = ServiceAccount.LocalSystem

        Return _installer
    End Function
    Private Function GetServiceInstaller() As ServiceInstaller
        Dim _installer As New ServiceInstaller
        Dim _service As Assembly
        Dim _config As Configuration

        _service = Assembly.GetAssembly(GetType(WinService))
        _config = ConfigurationManager.OpenExeConfiguration(_service.Location)

        _installer.ServiceName = _config.AppSettings.Settings("ServiceName").Value
        _installer.DisplayName = _config.AppSettings.Settings("DisplayName").Value
        _installer.Description = "SISBusines RabbitMQ Service for Customer and Invoice export / import"
        _installer.StartType = ServiceStartMode.Automatic

        Return _installer
    End Function

    Private Sub InitializeComponent()
        '    Me.serviceInstaller = New System.ServiceProcess.ServiceInstaller()
        '    Me.serviceProcessInstaller = New System.ServiceProcess.ServiceProcessInstaller()
        '    '
        '    'serviceInstaller
        '    '
        '    Me.serviceInstaller.Description = "SISBusines RabbitMQ Service for Customer and Invoice export / import"
        '    Me.serviceInstaller.DisplayName = "_Liba" 'ConfigurationManager.AppSettings("DisplayName")
        '    Me.serviceInstaller.ServiceName = "_Liba" 'ConfigurationManager.AppSettings("ServiceName")

        '    '
        '    'serviceProcessInstaller
        '    '
        '    Me.serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem
        '    '
        '    'WinInstaller
        '    '
        '    Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.serviceProcessInstaller, Me.serviceInstaller})

    End Sub

End Class