.NETGURU
How to start nt service after installing it?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.setup.

Post a new message to this list...

me
I have created a setup project for my service in vs.net and
added a custom action containing this code:

ServiceController controller = new ServiceController("myservice");
controller.Start();
controller.Close();

If I run the code standalone after installation, then it works fine
but after adding it as a custom action under "install" then i get
this message:

Cannot start service from the command line or debugger. A windows Service
must first be installed (using installutil.exe) and then started with the
ServerExplorer, Windows Services Administrative tool or the NET START command.

I was led to believe that custom actions run after the install has finished
but it dosent look like it. What is the right way to start the service
(programmably).
Reply to this message...
 
    
Phil Wilson
See if your code works if you put it in the Commit custom action. This might
correct two possible causes of the problem:
1. Your Service isn't fully installed until the Commit custom action is
called.
2. Your Service might have a dependency on an assembly in the GAC, and that
assembly isn't installed at the time your Install custom action is called.
Custom actions are not called when the install is finished. Other tools can
move them around in the install, but VS puts them in a fixed place before
the install has finished. All other tools I've ever seen that install
Services don't use custom actions because Windows Installer has built-in
support for installing them - these other tools just populate the
ServiceInstall and ServiceControl tables in the MSI file.
--
Phil Wilson
[MVP Windows Installer]
Definitive Guide to Windows Installer
http://www.amazon.com/exec/obidos/tg/detail/-/1590592972/104-7044380-4696760

"me" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
me
I get the same problem if I put it in commit. I have tried
the AfterInstall event too - same result. Also tried
overwriting commit() and install() on the projectinstaller
- same result.

That ServiceControl table you mention - can it be used to
start the service? and if so - how? I find it at bit mysterious
that msdn has lots of clear documentation on how to build
and install a service, but nothing on how to start it.

I havent got any old com objects that need removing, so it
should be fairly easy to start the service without rebooting.

"Phil Wilson" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
 
System.ServiceProcess.ServiceController




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification