/
ServiceWrapperInstaller.cs
41 lines (37 loc) · 1.14 KB
/
ServiceWrapperInstaller.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
using ServiceWrapper.Properties;
namespace ServiceWrapper
{
[RunInstaller(true)]
public class ServiceWrapperInstaller : Installer
{
protected static IServiceInstallHelper InstallHelper = new ServiceInstallHelper(false);
public ServiceWrapperInstaller()
{
var processInstaller = new ServiceProcessInstaller
{
Account = (ServiceAccount)
Enum.Parse(typeof (ServiceAccount), Settings.Default.ServiceAccount),
Username = Settings.Default.AccountUsername == string.Empty
? null
: Settings.Default.AccountUsername,
Password = Settings.Default.AccountPassword == string.Empty
? null
: Settings.Default.AccountPassword
};
var installer = new ServiceInstaller
{
DisplayName = InstallHelper.ServiceName,
StartType = (ServiceStartMode)
Enum.Parse(typeof(ServiceStartMode), Settings.Default.ServiceStartMode),
ServiceName = InstallHelper.ServiceName,
Description = Settings.Default.ServiceDescription
};
Installers.Add(processInstaller);
Installers.Add(installer);
}
}
}