473,698 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Log off user

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
5 3979
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
Tom,

* "Tom Spink" <thomasdotspink at@ntlworlddotc om> 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.or g/soft/class.qpx?id=7>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
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 HeWhoMustBeThro wnOut. :-)
.... or did I misinterpret the documentation?
Greetings,
Andy
"Tom Spink" <thomasdotspink at@ntlworlddotc om> schrieb im Newsbeitrag
news:eR******** ******@TK2MSFTN GP09.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
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 WTSLogoffSessio n API.

Take a look at this URI:
http://msdn.microsoft.com/library/de...tification.asp

for more information on the WTSLogoffSessio n 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 HeWhoMustBeThro wnOut. :-)
... or did I misinterpret the documentation?
Greetings,
Andy
"Tom Spink" <thomasdotspink at@ntlworlddotc om> schrieb im Newsbeitrag
news:eR******** ******@TK2MSFTN GP09.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
Thanks a lot, that sounds good! :-)

Andy

"Tom Spink" <thomasdotspink at@ntlworlddotc om> schrieb im Newsbeitrag
news:e2******** ******@TK2MSFTN GP11.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 WTSLogoffSessio n API.

Take a look at this URI:
http://msdn.microsoft.com/library/de...us/termserv/te
rmserv/wtsregistersess ionnotification .asp
for more information on the WTSLogoffSessio n 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 HeWhoMustBeThro wnOut. :-)
... or did I misinterpret the documentation?
Greetings,
Andy
"Tom Spink" <thomasdotspink at@ntlworlddotc om> schrieb im Newsbeitrag
news:eR******** ******@TK2MSFTN GP09.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
7271
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm The detector requires javascript 1.0 to work. This translates to netscape 2.0 and IE 3.0 (although maybe IE 2.0 also works with it)
3
4138
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability. The User Experience, or how the user experiences the end product, is the key to acceptance. And that is where User Interface Design enters the design process. While product engineers focus on the technology, usability specialists focus on the user...
6
11284
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
1
7580
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
7
2915
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
0
3932
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something like this is a bug or that .NET doesn't support what I trying to do. I hope that one that is is microsoft certified read this because this must be a bug.
2
4819
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be required: <%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %> Assuming that the ASPX page doesn't use a code-behind, I can access the properties, events etc. of the user control in the ASPX page in this way (assume that the ASPX page...
1
1970
by: Carlettus | last post by:
Dear All, sorry but I'm not sure if this is the right place to post my problem. I was using the following asp code to create users in Active Directory. Suddenly, and I don't know the reason, users are created but the account is disabled (see the flag User.AccountDisabled = False ). There is also another problem even if the user does not exist , the application returns to me with the message that the user already exist. Thank you for...
0
3230
by: rbukkara | last post by:
Hi, I have got the following error while trying to add a user in the LDAP Directory. javax.naming.NameNotFoundException: ; remaining name 'uid=vassila,ou=People,dc=cs,dc=uno,dc=edu' I have given all the attributes which are needed, for the user, in the code and also the proper path where the user has to be added. Please have a look at my code CODE] // This is a class file which stores all the info required for the user
9
6275
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who only has read access to the users table so that users can log in. Once a user has been logged in successfully I want to escalate that user's access level to one appropriate to their role, which will include switching the postgres user they are...
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.