473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to best determine any/all Logged On Users from a VB .NET Servi

I wrote a VB .NET Service to restart the computer when certain business rules
are triggered (such as not being rebooted in x days, no users logged on, time
is 1-3 am, etc.).

I am currently using a sloppy technique of checking the Registry to
determine if and who is logged on.

I would like to use a Microsoft sanctioned best-practice method of
determining if anyone is logged on (and their Username and all Process Names
that the User is running, etc.) from the Service. It will run on XP Pro, but
eventually Server 2003, etc.

I think I should be using the WindowStation and Desktop related API calls,
but cannot find good documentation on how to do it from Visual Basic .NET and
the proper sequence. I need some code snippets for something like,
EnumDesktops(), OpenWindowStation(), etc.

Any help from Microsoft ? (or anyone else that has done this).
Jul 21 '05 #1
2 4532
I would look into the WMI if I were you. I'm not sure if it has the info you
want, but it's a good start. You can get just about anything you need about
the system from the WMI.

David
"RickPowell" wrote:
I wrote a VB .NET Service to restart the computer when certain business rules
are triggered (such as not being rebooted in x days, no users logged on, time
is 1-3 am, etc.).

I am currently using a sloppy technique of checking the Registry to
determine if and who is logged on.

I would like to use a Microsoft sanctioned best-practice method of
determining if anyone is logged on (and their Username and all Process Names
that the User is running, etc.) from the Service. It will run on XP Pro, but
eventually Server 2003, etc.

I think I should be using the WindowStation and Desktop related API calls,
but cannot find good documentation on how to do it from Visual Basic .NET and
the proper sequence. I need some code snippets for something like,
EnumDesktops(), OpenWindowStation(), etc.

Any help from Microsoft ? (or anyone else that has done this).

Jul 21 '05 #2
Rick,
In addition to the other comments, you might be able to use the the
NetWkstaUserEnum Win32 api to retrieve the information.

I have not used it from a service yet.

http://groups-beta.google.com/group/...d390cf3dc29eec

(if the above link does not work, search groups.google.com for
NetWkstaUserEnum in the microsoft.public.dotnet.languages.vb newsgroup,
there is a thread from 9 Dec 2004 that discusses it & gives an example.)

Hope this helps
Jay
"RickPowell" <Ri********@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...
I wrote a VB .NET Service to restart the computer when certain business
rules
are triggered (such as not being rebooted in x days, no users logged on,
time
is 1-3 am, etc.).

I am currently using a sloppy technique of checking the Registry to
determine if and who is logged on.

I would like to use a Microsoft sanctioned best-practice method of
determining if anyone is logged on (and their Username and all Process
Names
that the User is running, etc.) from the Service. It will run on XP Pro,
but
eventually Server 2003, etc.

I think I should be using the WindowStation and Desktop related API
calls,
but cannot find good documentation on how to do it from Visual Basic .NET
and
the proper sequence. I need some code snippets for something like,
EnumDesktops(), OpenWindowStation(), etc.

Any help from Microsoft ? (or anyone else that has done this).

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: FLEB | last post by:
I'm working on a logon system, something generic and modular, as a part of a few ideas I have running. I'm just wondering, though, what is the best way to keep a user logged in authentically...
15
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not...
1
by: Mike Moore | last post by:
Does anyone have suggestions on the best way to check if a user is logged into asp.net web application? We are not using forms authentication. We are authenticating our users against active...
0
by: Marty Cruise | last post by:
I have a Windows Forms application that accesses an SQL Server DB. I would like to show a 'Messenger-like' listing of all users, and which of them are currently logged in to the system. How can I...
16
by: Jm | last post by:
Hi All Is it possible to determine who is logged onto a machine from inside a service using code in vb.net ? I have found some code that seems to work under vb6, but doesnt under .NET ? Any help...
2
by: RickPowell | last post by:
I wrote a VB .NET Service to restart the computer when certain business rules are triggered (such as not being rebooted in x days, no users logged on, time is 1-3 am, etc.). I am currently using...
40
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the...
3
by: =?Utf-8?B?aXdkdTE1?= | last post by:
Hi, im creating an application that will keep track of what users are logged into a network at a given time. all users must sign ingo this network first, so whenever a user is logged on, i will be...
5
by: Benedictum | last post by:
I need to implement an option to display on the web page for users currently logged in. How do I implement this in ASP.NET (c#). I could probably have a boolean field in the database where a user...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.