-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectInstaller.cs
More file actions
41 lines (36 loc) · 1.36 KB
/
ProjectInstaller.cs
File metadata and controls
41 lines (36 loc) · 1.36 KB
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.ComponentModel;
using System.ServiceProcess;
namespace MyDatabaseBackupService
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
// Service Process Installer
var serviceProcessInstaller = new ServiceProcessInstaller
{
Account = ServiceAccount.LocalSystem // Use LocalSystem or a specific user account with permissions
};
// Service Installer
var serviceInstaller = new ServiceInstaller
{
ServiceName = "MyBackupService",
DisplayName = "My Backup Service",
Description = "A service that creates database backups on a schedule.",
StartType = ServiceStartMode.Automatic // Automatically start the service on boot
};
// Set Dependencies
serviceInstaller.ServicesDependedOn = new string[]
{
"MSSQLSERVER", // SQL Server
"Schedule", // Task Scheduler service
"eventlog" // Event Log service
};
// Add installers to collection
Installers.Add(serviceProcessInstaller);
Installers.Add(serviceInstaller);
}
}
}