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

G

Guest

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).
 
G

Guest

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
 
J

Jay B. Harlow [MVP - Outlook]

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..._doneTitle=Back+to+Search&&d#30d390cf3dc29eec

(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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top