By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,807 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,807 IT Pros & Developers. It's quick & easy.

Stopping service from within OnStart sub

P: n/a
In the OnStart sub of my service (as the service is starting up) I check for
certain things. If one of a few things don't jive, I want to "cancel" the
starting of the service.

How do I accomplish this? Currently I am using the Stop method of the
ServiceController but that does not seem to be working.

Is it possible to "stop the start" of a service half way through its Start?
Are there other options?

Scott
--
Thanks,

Scott
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"SQLScott" <SQ******@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
In the OnStart sub of my service (as the service is starting up) I check
for
certain things. If one of a few things don't jive, I want to "cancel" the
starting of the service.

How do I accomplish this? Currently I am using the Stop method of the
ServiceController but that does not seem to be working.

Is it possible to "stop the start" of a service half way through its
Start?
Are there other options?


Sure. Just write an event log entry describing the failure and throw an
exception.

David
Nov 21 '05 #2

P: n/a
Scott,
Its (can be) even easier then David suggests.

Just throw an exception!

ServiceBase itself will write an entry to the event log for you if you have
ServiceBase.AutoLog property set to true. AutoLog=True is the default
setting...

Hope this helps
Jay
"SQLScott" <SQ******@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
In the OnStart sub of my service (as the service is starting up) I check
for
certain things. If one of a few things don't jive, I want to "cancel" the
starting of the service.

How do I accomplish this? Currently I am using the Stop method of the
ServiceController but that does not seem to be working.

Is it possible to "stop the start" of a service half way through its
Start?
Are there other options?

Scott
--
Thanks,

Scott

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.