[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to start windows service automatically after installation?

Posted on 2007-07-30
6
Medium Priority
?
642 Views
Last Modified: 2013-11-07
Hi, experts:

i have a very simple windows service and the setup file is ready to go. However, i still have to manually start the windows service after installation. is there anyway to automatically start the service after the installation?

thanks
0
Comment
Question by:viola123
  • 3
  • 2
6 Comments
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 19596811
From the command line you need to execute 'net start <service name>'
0
 
LVL 6

Author Comment

by:viola123
ID: 19597544
thanks tedbilly

but i guess i meant how to incorporate this in the setup file. in another word, the installation file should be able to complete installtion and start the service, rather than open console window and use command line.
0
 
LVL 10

Expert Comment

by:ericwong27
ID: 19598850
- Extend the ServiceInstaller class and register an Event handler for the
base class "Committed" event in the class constructor.

- In your Event handler you just create an instance of the ServiceController
class for your service and call it's Start method.

- Optionally you can wait for the service to start by calling
ServiceController .WaitForStatus before you close the ServiceController by
calling Close.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 19606465
I didn't mean to manually do it in the command line.  I don't know which tool you have used to create the installer, however, you could write a batch file to execute the setup.exe then run the command line in the batch file.
0
 
LVL 6

Author Comment

by:viola123
ID: 19622448
hi,tedbilly:

I have to create a setup project in vs studio 2005. how to add your command line in that case??

thx
0
 
LVL 51

Accepted Solution

by:
Ted Bouskill earned 2000 total points
ID: 19622720
When building a setup project in VS 2005 you can create custom actions that fire when the installation is committed.  At that point you can run your own custom EXE which can be an application that can do anything you need including interacting with the operating system to start or stop a service.

You custom exe can either execute a command line instruction or directly start or stop the service programmically.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question