473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1888
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_ma y" <None> wrote in message
news:uX******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP15.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 RegisterService CtrlHandlerEx (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 RegisterService CtrlHandler
& RegisterService CtrlHandlerEx from you... Again I would recommend you ask
in a Win32 newsgroup on the specifics of RegisterService CtrlHandler &
RegisterService CtrlHandlerEx.. .

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

Hope this helps
Jay

"gregory_ma y" <None> wrote in message
news:uX******** ******@TK2MSFTN GP12.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.publi c.win32.program mer.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 ServiceControll er.Stop or Process.CloseMa inWindow. 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_ma y" <None> wrote in message
news:uP******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP15.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 RegisterService CtrlHandlerEx (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 RegisterService CtrlHandler
& RegisterService CtrlHandlerEx from you... Again I would recommend you
ask in a Win32 newsgroup on the specifics of RegisterService CtrlHandler &
RegisterService CtrlHandlerEx.. .

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

Hope this helps
Jay

"gregory_ma y" <None> wrote in message
news:uX******** ******@TK2MSFTN GP12.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
1894
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 case, i.e. "the REMAINS of the DAY" is converted to "The Remains Of The Day". This function is particularly good in that it handles certain exceptions. Can you help me make it handle more? I'm interested in two tweaks, one easy, one hard.
1
5491
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 provide any feedback to the overall comparison between these 2 products as I am finding RS frustrating and am wondering if it is just a matter of re-adjusting and spending more time on it or if anyone else is finding RS more trickey to use than...
7
3204
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 enough for me but I'm having a brain block when it comes to TimeZone. The datetime may come with an optional timezone offset (from GMT) as here (the offset is +1 hour from GMT):
7
10849
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 tried to use the colormatrix and even down to the pixel using GetPixel and SetPixel in system.drawing, but I'm really not up on using gdi+ and haven't really gotten anywhere. I've seen some examples for VB6, but I need vb.net. I know that all...
1
1506
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, the labels fit perfectly to the A4 label sheets I have. The problem I have is that I want to the report to be dynamic. If I purchase a different style of label, I need to go into the design of the report to modify widths, heights, column counts,...
1
1042
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 when trying to write to the file, I've tried adjusting the permissions accordingly but they don't seem to make any difference.
2
2112
by: pramodh | last post by:
adjusting the baseline of an external text to import in flash
5
6691
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 (ctrl-UpArrow and ctrl-DnArrow), and attached handlers that execute this code: public partial class MainForm : Form { . . . dataGridView.RowTemplate.Height += increment; Refresh();
3
3896
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
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.