I tried as your code in vb
.net but it is not start once when I finish install. Please help.
Public Overrides Sub Commit(ByVal savedState As IDictionary)
Dim serviceName As String = "MyService"
Dim serviceController As New System.ServiceProcess.ServiceController(serviceNam e)
quote:Originally posted by ejan
The StartType property specifies the behavior of a service at system startup. It doesn't address the issue of starting a service after you install a Windows Service using the Setup Project.
There are two ways you can address this issue: either instruct your user to restart the computer after installation or write an installer class for starting your service after it gets installed.
You will need to create a library with a class that derives from the System.Configuration.Install.Installer class. Decorate your class with [RunInstaller(true)]. Now override the OnCommitted method and write the following code inside the method:
string serviceName = "<your_service_name>";
ServiceController serviceController =
Compile the project and add its output to the Commit custom action of your Setup project that installs your service. This will start your service as soon as it's installed. Setting the StartType property to Automatic will ensure your service starts automatically each time the computer starts.
Hopefully this helps.