
This is not the Actual “Installer”. This is code needed for the Service to operate correctly.
We will get to Installing Later…
Add the Installer Code:
Create a new class file in your project and call it ProjectInstaller.
We wil replace the text in the ProjectInstaller class with the following code:
Version:0.9 StartHTML:0000000100 EndHTML:0000012095 StartFragment:0000000100 EndFragment:0000012095
1 Imports System.ComponentModel
2 Imports System.Configuration.Install
3
4 <RunInstaller(True)> Public Class ProjectInstaller
5 Inherits System.Configuration.Install.Installer
6 ‘Installer overrides dispose to clean up the component list.
7
8 <System.Diagnostics.DebuggerNonUserCode()> _
9 Protected Overrides Sub Dispose(ByVal disposing As Boolean)
10 Try
11 If disposing AndAlso components IsNot Nothing Then
12 components.Dispose()
13 End If
14 Finally
15 MyBase.Dispose(disposing)
16 End Try
17 End Sub
18
19 ‘Required by the Component Designer
20 Private components As System.ComponentModel.IContainer
21
22 ‘NOTE: The following procedure is required by the Component Designer
23 ‘It can be modified using the Component Designer.
24 ‘Do not modify it using the code editor.
25
26 <System.Diagnostics.DebuggerStepThrough()> _
27 Private Sub InitializeComponent()
28 Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller
29 Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller
30 ‘
31 ‘ServiceProcessInstaller1
32 ‘
33 Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem
34 Me.ServiceProcessInstaller1.Password = Nothing
35 Me.ServiceProcessInstaller1.Username = Nothing
36 ‘
37 ‘ServiceInstaller1
38 ‘
39 Me.ServiceInstaller1.ServiceName = “NewService1”
40 Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic
41 ‘
42 ‘ProjectInstaller
43 ‘
44 Me.Installers.AddRange(New System.Configuration.Install.Installer() _
45 {Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
46 End Sub
47
48 Friend WithEvents ServiceProcessInstaller1 As _
49 System.ServiceProcess.ServiceProcessInstaller
50
51 Friend WithEvents ServiceInstaller1 As _
52 System.ServiceProcess.ServiceInstaller
53
54 Public Sub New()
55 MyBase.New()
56
57 ‘This call is required by the Component Designer.
58 InitializeComponent()
59
60 ‘Add initialization code after the call to InitializeComponent
61
62 End Sub
63 End Class
This will create the ProjectInstaller class and insert 2 Objects in the designer:

ServiceInstaller1 – Settings: The Service Name, Display Name, description, StartType
ServiceProcessInstaller – Settings: The Account the service will run under
In this example, the settings are set as follows:
ServiceName: NewService1
DisplayName: {blank}
Description: {blank}
StartType: Automatic – (will auto start on reboot)
Account: LocalSystem – (do not need user/password. This will run under System account)
Now we have to build the project.
Services Part 3:> Build and Install your Service