468,242 Members | 1,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

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 4176
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by FLEB | last post: by
15 posts views Thread by Joshua Beall | last post: by
3 posts views Thread by =?Utf-8?B?aXdkdTE1?= | last post: by
5 posts views Thread by Benedictum | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.