473,466 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Detect if user is logged in

How do a windows-service detect whether a user is logged or not on a computer?

So far i've found nothing in the windows api or any code examples that will allow me to figure this out.

The solution i have today is to use Diagnostics.Process.GetProcesses and then iterate through the array i get and look for
explorer.exe
Explorer.exe is not loaded when a user is logged out of a computer.

I found this on winlogon states:
http://msdn.microsoft.com/library/de...gon_states.asp
but i cant see any api methods that will return the state that winlogon is actually in...

the only solution getting close to this issue i found at http://weblogs.asp.net/ralfw/archive.../04/47388.aspx but that dosent
work.
Jan 21 '06 #1
4 10068
Hi,

Are you looking to see who the machine is logged in as or if a
user is logged into your active directory? What version of vb are you using?

Ken
---------------------

"Jarod_24" wrote:
How do a windows-service detect whether a user is logged or not on a computer?

So far i've found nothing in the windows api or any code examples that will allow me to figure this out.

The solution i have today is to use Diagnostics.Process.GetProcesses and then iterate through the array i get and look for
explorer.exe
Explorer.exe is not loaded when a user is logged out of a computer.

I found this on winlogon states:
http://msdn.microsoft.com/library/de...gon_states.asp
but i cant see any api methods that will return the state that winlogon is actually in...

the only solution getting close to this issue i found at http://weblogs.asp.net/ralfw/archive.../04/47388.aspx but that dosent
work.

Jan 21 '06 #2
>How do a windows-service detect whether a user is logged or not on a computer?

Why do you need to know that?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 21 '06 #3
Im writing a power saving service that runs on a computer and i need to see if a user is logged in on the machine that the service
itself is installed on.
No active directory. Basically, if there is a user logged in, the service will for example do a Hibernate, but if there is no user
logged in, then it will to a Shutdown.

Im using VS2003.
"Ken Tucker [MVP]" <Ke**********@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Hi,

Are you looking to see who the machine is logged in as or if a
user is logged into your active directory? What version of vb are you using?

Ken
---------------------

"Jarod_24" wrote:
How do a windows-service detect whether a user is logged or not on a computer?

So far i've found nothing in the windows api or any code examples that will allow me to figure this out.

The solution i have today is to use Diagnostics.Process.GetProcesses and then iterate through the array i get and look for
explorer.exe
Explorer.exe is not loaded when a user is logged out of a computer.

I found this on winlogon states:
http://msdn.microsoft.com/library/de...gon_states.asp
but i cant see any api methods that will return the state that winlogon is actually in...

the only solution getting close to this issue i found at http://weblogs.asp.net/ralfw/archive.../04/47388.aspx but that
dosent
work.

Jan 21 '06 #4
Hi,

Not really sure if this will work but maybe you could use the
win32_operatingsystems numberofusers property. Add a reference to
system.management

Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_OperatingSystem")
moReturn = moSearch.Get

For Each mo In moReturn

Try
Trace.WriteLine(mo("NumberOfUsers").ToString)
Catch ex As System.Exception
Trace.WriteLine(ex.ToString)
End Try

Next
http://msdn.microsoft.com/library/de...tingsystem.asp

Ken
-----------------

"Jarod_24" <ja******@hotmail.com> wrote in message
news:43**********************@titian.nntpserver.co m...
Im writing a power saving service that runs on a computer and i need to
see if a user is logged in on the machine that the service itself is
installed on.
No active directory. Basically, if there is a user logged in, the service
will for example do a Hibernate, but if there is no user logged in, then
it will to a Shutdown.

Im using VS2003.
"Ken Tucker [MVP]" <Ke**********@discussions.microsoft.com> wrote in
message news:88**********************************@microsof t.com...
Hi,

Are you looking to see who the machine is logged in as or if a
user is logged into your active directory? What version of vb are you
using?

Ken
---------------------

"Jarod_24" wrote:
How do a windows-service detect whether a user is logged or not on a
computer?

So far i've found nothing in the windows api or any code examples that
will allow me to figure this out.

The solution i have today is to use Diagnostics.Process.GetProcesses and
then iterate through the array i get and look for
explorer.exe
Explorer.exe is not loaded when a user is logged out of a computer.

I found this on winlogon states:
http://msdn.microsoft.com/library/de...gon_states.asp
but i cant see any api methods that will return the state that winlogon
is actually in...

the only solution getting close to this issue i found at
http://weblogs.asp.net/ralfw/archive.../04/47388.aspx but that
dosent
work.


Jan 21 '06 #5

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

Similar topics

1
by: Gaurav | last post by:
Hi, is there a way to know which user last logged in the shared Access database. My requirement is that I must be able to track the users that log in the database and incase its not working...
2
by: Joe Saliba | last post by:
hi, hope somebody could help me with this, have some users created on an sql 2000, and am trying to know which user opened the adp , so everytime i put msgobx currentuser it gives me admin, though...
4
by: Chumma Dede | last post by:
Hi, Is there any way in asp.net 1.1 to force a user to logout from an existing session on machine1, if that same userid logs in with a new session on another machine, say machine2? We are...
4
by: Rik Hemsley | last post by:
Hi, Our web application impersonates a domain user when it runs. Usually, the printers visible to the application are the same as those visible to the domain user. At one installation, the...
0
by: BLUE | last post by:
EventLogPermission permission = new EventLogPermission(EventLogPermissionAccess.Administer, "."); permission.PermitOnly(); If I use the above statements before CreateEventSource when I go to...
7
by: whutto | last post by:
I have a VB.NET app that crashes when run from the Windows scheduled tasks, but runs fine when the run-as user is logged on. The app also runs fine from the scheduled jobs if the run as user is...
2
by: RP | last post by:
I want to detect user activity (mouse move, key click). For certain critical areas (Form in my app.), I want to check whether there is any user activity for a certain interval. If not, then I want...
2
by: Viza | last post by:
Can I get some suggestions on how I can tell if a user is logged in remotely on a Win XP Pro box and kill a certain process? Any solutions are welcome.
1
by: Nate.Baxley | last post by:
I have a site that I want to keep the user logged in after they leave the site if they check the "Remember Me" box. How do I go about doing this? Lengthen the session length? Any help would be...
18
by: sebastian | last post by:
Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found that sometimes the old session data remained even after the user left the site...
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
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...
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,...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.