By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,865 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,865 IT Pros & Developers. It's quick & easy.

Log off user

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
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

Nov 20 '05 #2

P: n/a
Tom,

* "Tom Spink" <thomasdotspinkat@ntlworlddotcom> scripsit:
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


Maybe the OP can base his implementation on this sample:

<http://www.mentalis.org/soft/class.qpx?id=7>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
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
"Tom Spink" <thomasdotspinkat@ntlworlddotcom> schrieb im Newsbeitrag
news:eR**************@TK2MSFTNGP09.phx.gbl...
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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
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


Nov 20 '05 #4

P: n/a
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/de...tification.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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
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
"Tom Spink" <thomasdotspinkat@ntlworlddotcom> schrieb im Newsbeitrag
news:eR**************@TK2MSFTNGP09.phx.gbl...
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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
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



Nov 20 '05 #5

P: n/a
Thanks a lot, that sounds good! :-)

Andy

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> schrieb im Newsbeitrag
news:e2**************@TK2MSFTNGP11.phx.gbl...
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/de...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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
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
"Tom Spink" <thomasdotspinkat@ntlworlddotcom> schrieb im Newsbeitrag
news:eR**************@TK2MSFTNGP09.phx.gbl...
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
"Andreas Müller" <an*************@uni-essen.de> wrote in message
news:c1*************@ID-175356.news.uni-berlin.de...
> 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
>
>



Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.