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

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.