public void Install()
{
if (ServiceExists())
{
logger.Warn("The service is already installed!");
}
else
{
var installer = new ServiceProcessInstaller
{
Account = ServiceAccount.LocalSystem
};
var serviceInstaller = new ServiceInstaller();
var exePath = Path.Combine(configService.ApplicationFolder(), SERVICEEXE);
if (!File.Exists(exePath) && Debugger.IsAttached)
{
exePath = Path.Combine(configService.ApplicationFolder(), "..\\..\\..\\Jackett.Service\\bin\\Debug", SERVICEEXE);
}
string[] cmdline = { @"/assemblypath=" + exePath};
var context = new InstallContext("jackettservice_install.log", cmdline);
serviceInstaller.Context = context;
serviceInstaller.DisplayName = NAME;
serviceInstaller.ServiceName = NAME;
serviceInstaller.Description = DESCRIPTION;
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.Parent = installer;
serviceInstaller.Install(new ListDictionary());
}
}