RodionP
asked on
Creating a deployment package for service
Hello I have an application that is a system service, and now I have to create a deployment package for it.
After installation I need my service to start automatically, and start everytime windows starts.
What do I have to do ?
After installation I need my service to start automatically, and start everytime windows starts.
What do I have to do ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the installer code for your service, include the following:
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount. LocalSystem;
ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "Your Service Name";
si.DisplayName = "Your service name";
si.StartType = ServiceStartMode.Automatic ; // THIS IS THE IMPORTANT LINE!!!!!!!
this.Installers.Add(si);
this.Installers.Add(spi);
Then register the service as usual.
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount. LocalSystem;
ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "Your Service Name";
si.DisplayName = "Your service name";
si.StartType = ServiceStartMode.Automatic
this.Installers.Add(si);
this.Installers.Add(spi);
Then register the service as usual.
P.S. After you register the service, you need to restart the computer to start the service.
thx very much
with downloadable sample
http://www.codeproject.com/dotnet/simplewindowsservice.asp