Re: Adjusting a services "CanStop" on the fly?
From: gregory_may (None)
Date: 02/05/05
- Next message: Herfried K. Wagner [MVP]: "Re: ToString()"
- Previous message: Cor Ligthert: "Re: .Net Framework"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 5 Feb 2005 09:20:30 -0800
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]" <Jay_Harlow_MVP@msn.com> wrote in message
news:ujDukI0CFHA.2756@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:uXB22hvCFHA.2756@TK2MSFTNGP12.phx.gbl...
>> According to this article, I cant change "CanStop" on the fly!!!
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemserviceprocessservicebaseclasscanstoptopic.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/default.asp?url=/library/en-us/dllproc/base/window_station_and_desktop_functions.asp
>>
>>
>>
>>
>>
>>
>
>
- Next message: Herfried K. Wagner [MVP]: "Re: ToString()"
- Previous message: Cor Ligthert: "Re: .Net Framework"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Adjusting a services "CanStop" on the fly?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|