473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adjusting a services "CanStop" on the fly?

According to this article, I cant change "CanStop" on the fly!!!

http://msdn.microsoft.com/library/de...nstoptopic.asp

So, how can I enable/disable the ability for a user to kill my service (Via
Task Manager) on the fly?

I would prefer not to tweak the regestry settings that permit Task manager
from be available to a user. I have not had good luck down this path & task
manager needs to be available for other reasons.

I was hoping for a way to disable someone from killing my service if they
dont have the Administrative Privledge.

If I understand things correctly, the thread that a user will be running
under is not known at the time the service starts. Users can log off/On
with different privledges.

I was also unsuccessfull at navigating the windows station to deturmine who
is trying to kill the service. This article covers all the functions
relating to figuring out who is logged in. With fast user switching under
XP, several users can actually be logged into the PC at one time.
http://msdn.microsoft.com/library/de..._functions.asp


Nov 21 '05 #1
3 1868
Maybe a good follow up question is if someone kills my service in Task
Manager if the OnStop event gets fired?

I am really tring to protect against a TaskManager Hard Kill, if they stop
the service via the Control Manager, thats ok.

"gregory_may" <None> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
According to this article, I cant change "CanStop" on the fly!!!

http://msdn.microsoft.com/library/de...nstoptopic.asp

So, how can I enable/disable the ability for a user to kill my service
(Via Task Manager) on the fly?

I would prefer not to tweak the regestry settings that permit Task manager
from be available to a user. I have not had good luck down this path &
task manager needs to be available for other reasons.

I was hoping for a way to disable someone from killing my service if they
dont have the Administrative Privledge.

If I understand things correctly, the thread that a user will be running
under is not known at the time the service starts. Users can log off/On
with different privledges.

I was also unsuccessfull at navigating the windows station to deturmine
who is trying to kill the service. This article covers all the functions
relating to figuring out who is logged in. With fast user switching under
XP, several users can actually be logged into the PC at one time.
http://msdn.microsoft.com/library/de..._functions.asp


Nov 21 '05 #2
Thanks!

I have been thinking this over pretty hard. I am willing to just make the
service "CanStop" for everyone .... as long as Task Manager cant kill it
(This is what I really want to fix).

I posted this question to the .Net framework, but I will repost in win32
(Which win32 do you suggest, none of them seem to be a good fit for this
question).

Thanks!

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uj**************@TK2MSFTNGP15.phx.gbl...
Gregory,
I was also unsuccessfull at navigating the windows station to deturmine
who is trying to kill the service.

Which is what I stated in my other post, I really don't think you can
determine who is trying to kill the service. This would really be a Win32
question, you probably want to ask in a Win32 newsgroup!
So, how can I enable/disable the ability for a user to kill my service
(Via Task Manager) on the fly?

Again, as you found out, you can't change the setting on the fly, as it
doesn't really make sense to. What should the setting be when there is an
Admin logged in & a Non-Admin logged in? Don't forget other services can
control your service & each service is "logged in" to Windows...
I have not tried it, what happens if the OnStop method throws an
exception? Does the service still stop or will the stopping of the service
be aborted? I know if OnStart throws an exception the starting of the
service is aborted. I just don't know about the stopping. An exception may
abort the stopping of the service, keeping the service going, or it may
simply keep stopping the service... Of course you would still need to
figure out who actually made the request to decide if you should throw the
exception...

It appears the RegisterServiceCtrlHandlerEx (a Win32 API) supports a
SERVICE_CONTROL_SESSIONCHANGE event, which notifies a service of session
change events. You could possibly use this event to be notified when the
"current user" changes from an Admin user & a non Admin user,
unfortunately ServiceBase hides the details of RegisterServiceCtrlHandler
& RegisterServiceCtrlHandlerEx from you... Again I would recommend you ask
in a Win32 newsgroup on the specifics of RegisterServiceCtrlHandler &
RegisterServiceCtrlHandlerEx...

Of course I may simply be miss reading what SERVICE_CONTROL_SESSIONCHANGE
really telling me...

Hope this helps
Jay

"gregory_may" <None> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
According to this article, I cant change "CanStop" on the fly!!!

http://msdn.microsoft.com/library/de...nstoptopic.asp

So, how can I enable/disable the ability for a user to kill my service
(Via Task Manager) on the fly?

I would prefer not to tweak the regestry settings that permit Task
manager from be available to a user. I have not had good luck down this
path & task manager needs to be available for other reasons.

I was hoping for a way to disable someone from killing my service if
they dont have the Administrative Privledge.

If I understand things correctly, the thread that a user will be running
under is not known at the time the service starts. Users can log
off/On with different privledges.

I was also unsuccessfull at navigating the windows station to deturmine
who is trying to kill the service. This article covers all the functions
relating to figuring out who is logged in. With fast user switching
under XP, several users can actually be logged into the PC at one time.
http://msdn.microsoft.com/library/de..._functions.asp



Nov 21 '05 #3
Gregory,
When I can't find a specific group, I normally go for the most general
group, general win32 programming in this case that is, probably
microsoft.public.win32.programmer.kernel

The danger of course is someone may suggest go to the .NET group, so try to
"hide" the fact its a .NET question...

Hopefully someone in the general group will redirect you to a more specific
group if there is one...
as long as Task Manager cant kill it (This is what I really want to fix).
I would think Task Manager does the Win32 equivalent of Process.Kill rather
then the more polite ServiceController.Stop or Process.CloseMainWindow. In
other words I would not expect Task Manager to honor the CanStop property,
rather it simply does: Ready, Aim, Fire!

Hope this helps
Jay

"gregory_may" <None> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl... Thanks!

I have been thinking this over pretty hard. I am willing to just make the
service "CanStop" for everyone .... as long as Task Manager cant kill it
(This is what I really want to fix).

I posted this question to the .Net framework, but I will repost in win32
(Which win32 do you suggest, none of them seem to be a good fit for this
question).

Thanks!

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uj**************@TK2MSFTNGP15.phx.gbl...
Gregory,
I was also unsuccessfull at navigating the windows station to deturmine
who is trying to kill the service.

Which is what I stated in my other post, I really don't think you can
determine who is trying to kill the service. This would really be a Win32
question, you probably want to ask in a Win32 newsgroup!
So, how can I enable/disable the ability for a user to kill my service
(Via Task Manager) on the fly?

Again, as you found out, you can't change the setting on the fly, as it
doesn't really make sense to. What should the setting be when there is an
Admin logged in & a Non-Admin logged in? Don't forget other services can
control your service & each service is "logged in" to Windows...
I have not tried it, what happens if the OnStop method throws an
exception? Does the service still stop or will the stopping of the
service be aborted? I know if OnStart throws an exception the starting of
the service is aborted. I just don't know about the stopping. An
exception may abort the stopping of the service, keeping the service
going, or it may simply keep stopping the service... Of course you would
still need to figure out who actually made the request to decide if you
should throw the exception...

It appears the RegisterServiceCtrlHandlerEx (a Win32 API) supports a
SERVICE_CONTROL_SESSIONCHANGE event, which notifies a service of session
change events. You could possibly use this event to be notified when the
"current user" changes from an Admin user & a non Admin user,
unfortunately ServiceBase hides the details of RegisterServiceCtrlHandler
& RegisterServiceCtrlHandlerEx from you... Again I would recommend you
ask in a Win32 newsgroup on the specifics of RegisterServiceCtrlHandler &
RegisterServiceCtrlHandlerEx...

Of course I may simply be miss reading what SERVICE_CONTROL_SESSIONCHANGE
really telling me...

Hope this helps
Jay

"gregory_may" <None> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
According to this article, I cant change "CanStop" on the fly!!!

http://msdn.microsoft.com/library/de...nstoptopic.asp

So, how can I enable/disable the ability for a user to kill my service
(Via Task Manager) on the fly?

I would prefer not to tweak the regestry settings that permit Task
manager from be available to a user. I have not had good luck down this
path & task manager needs to be available for other reasons.

I was hoping for a way to disable someone from killing my service if
they dont have the Administrative Privledge.

If I understand things correctly, the thread that a user will be running
under is not known at the time the service starts. Users can log
off/On with different privledges.

I was also unsuccessfull at navigating the windows station to deturmine
who is trying to kill the service. This article covers all the
functions relating to figuring out who is logged in. With fast user
switching under XP, several users can actually be logged into the PC at
one time.
http://msdn.microsoft.com/library/de..._functions.asp




Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ken Fine | last post by:
No joy on Macromedia's boards after a few days; maybe someone can help me here. I got an excellent string handling function off of planet-source-code.com that converts text strings to proper...
1
by: lak | last post by:
Hi, I am evaluating Microsoft Reporting Services against Business Objects as a reporting tool against SQL Server. I am primarily a BOBJ developer and am finding RS not easy to use. Can anyone...
7
by: Jim Davis | last post by:
I'm (still) working on an ISO 8601 date parser. I want to convert at least the formats described here: http://www.w3.org/TR/NOTE-datetime Well.. I've got most of it working (via RegEx's) good...
7
by: marfi95 | last post by:
I'm trying to implement some code in vb.net to allow the user to adjust the brightness or contrast on an image (through the use of a slider) that is already black & white in the bitmap. I have...
1
by: Mark | last post by:
Hi All, I have set up a simple database to create labels for bottles. I insert a set number of records into a table and have produced a label report based on that table. After a bit of tweaking,...
1
by: Mantorok | last post by:
Hi 2000 Server IIS 5 I have a web service using anonymous access, however I need to be able to output to a log file. I've got a log.txt file in the same directory but I keep getting errors...
2
by: pramodh | last post by:
adjusting the baseline of an external text to import in flash
5
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to be able to increase or decrease row heights of a populated DataGridView from the keyboard. I set up a test program with menu items to increase and decrease, assigned shortkey keys...
3
by: bmahussain | last post by:
Anybody having javascript coding for adjusting brightness and contrast of an image using slider control. If yes, then kindly forward the same. regards, hussain.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.