Create Windows service that captures shutdown.

Create Windows service that captures shutdown.

am 03.04.2008 11:11:22 von Ben_

Hi,

as title suggests, I want to create a windows service that can be
notified that the computer is shutting down. When it receives this
signal it needs to block for about 10 seconds to write some stuff to a
file before allowing the machine to continue with shutdown (or possible
stop the shutdown if there was an error so that the user can be informed)

I am using Visual Studio.NET 2003 and used the windows service template
that it provided. I see that the template has a 'CanShutdown' property
which means that it should get the shutdown signal when it is
terminating but I don't this this will be anygood for cancelling the
shutdown if need be.

Does anyone know if there is a way to cancel the shutdown without having
to create a window and capturing the WM_QUERYENDSESSION message?

Regards,

John.

RE: Create Windows service that captures shutdown.

am 07.04.2008 06:58:00 von Chris

Hi,
You might want to look into WMI. Might be a place to start.

Thanks

"John" wrote:

> Hi,
>
> as title suggests, I want to create a windows service that can be
> notified that the computer is shutting down. When it receives this
> signal it needs to block for about 10 seconds to write some stuff to a
> file before allowing the machine to continue with shutdown (or possible
> stop the shutdown if there was an error so that the user can be informed)
>
> I am using Visual Studio.NET 2003 and used the windows service template
> that it provided. I see that the template has a 'CanShutdown' property
> which means that it should get the shutdown signal when it is
> terminating but I don't this this will be anygood for cancelling the
> shutdown if need be.
>
> Does anyone know if there is a way to cancel the shutdown without having
> to create a window and capturing the WM_QUERYENDSESSION message?
>
> Regards,
>
> John.
>

Re: Create Windows service that captures shutdown.

am 07.04.2008 13:52:35 von Ben_

Chris wrote:
> Hi,
> You might want to look into WMI. Might be a place to start.
>
> Thanks
>
> "John" wrote:
>
>> Hi,
>>
>> as title suggests, I want to create a windows service that can be
>> notified that the computer is shutting down. When it receives this
>> signal it needs to block for about 10 seconds to write some stuff to a
>> file before allowing the machine to continue with shutdown (or possible
>> stop the shutdown if there was an error so that the user can be informed)
>>
>> I am using Visual Studio.NET 2003 and used the windows service template
>> that it provided. I see that the template has a 'CanShutdown' property
>> which means that it should get the shutdown signal when it is
>> terminating but I don't this this will be anygood for cancelling the
>> shutdown if need be.
>>
>> Does anyone know if there is a way to cancel the shutdown without having
>> to create a window and capturing the WM_QUERYENDSESSION message?
>>
>> Regards,
>>
>> John.
>>

Hi,

WMI looks very useful indeed. I think I've got a alot of reading to do now.

Thanks for the pointer.

Regards,

John.