Log off user

  • Thread starter Thread starter Andreas Müller
  • Start date Start date
A

Andreas Müller

Hi!
I've been looking for a way to log off another user from Windows XP, that is
to terminate his session without having to shutdown Windows. My goal is to
write a service (preferrably running under System privileges) which is able
to log off users after a defined time. Since other users may be logged on as
well, it would be quite an unelegant and questionable way to simply use
ExitWindows or something of this kind.
Since the task manager provides this kind of feature (under WinXP Pro at
least outside of a domain), I figure there must be a way to do it by code.
Does anyone have any suggestions (API calls, WMI,...)?
Thanks very much in advance!

Andy
 
Hi Andreas,

ExitWindowsEx should be the API call you are looking for, by specifying the
correct parameter, it can log off the current user. Take a look on Google,
there are countless examples around

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Hi, Tom!
Thanks for your quick reply, but that's unfortunately not the solution. As
you correctly stated, ExitWindowsEx can log off the CURRENT user, but not
any specified user. Running as user "System", as far as I understand the
function would try to log off System (which would be disastrous, could it be
done), but not the user named HeWhoMustBeThrownOut. :-)
.... or did I misinterpret the documentation?
Greetings,
Andy
 
Ahh right, I misunderstood your original post. Fair enough.

To accomplish this, you'll need the session ID for the user you're trying to
log off, then call the WTSLogoffSession API.

Take a look at this URI:
http://msdn.microsoft.com/library/d...v/termserv/wtsregistersessionnotification.asp

for more information on the WTSLogoffSession API call.

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Thanks a lot, that sounds good! :-)

Andy

Tom Spink said:
Ahh right, I misunderstood your original post. Fair enough.

To accomplish this, you'll need the session ID for the user you're trying to
log off, then call the WTSLogoffSession API.

Take a look at this URI:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/te
rmserv/wtsregistersessionnotification.asp

for more information on the WTSLogoffSession API call.

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
it Pro
 
Back
Top