Re: Finding what user is logged in.

From: Chuck Chopp (
Date: 08/11/05

Date: Thu, 11 Aug 2005 08:32:25 -0400

peeldog wrote:

> I am trying to write an NT Service that will start a task 5 mins after a user
> logs out, and terminate it as soon as they log back in again. Should I be
> using the console Handler routine to catch the logoff event? Or should I
> poll OpenWindowStation?

On Win2K [w/TS enabled] and Win2K3 servers, as well as WinXP systems, I've
had my services monitor the Terminal Services events so that *any* session,
including the console, can be monitored for logon & logoff events.

There's also Winlogon Notification Packages that you can write that will
tell you about these sorts of events, too.

Chuck Chopp
ChuckChopp (at) rtfmcsi (dot) com
RTFM Consulting Services Inc.     864 801 2795 voice & voicemail
103 Autumn Hill Road              864 801 2774 fax
Greer, SC  29651
Do not send me unsolicited commercial email.