Link to home
Start Free TrialLog in
Avatar of KenLevin
KenLevinFlag for United States of America

asked on

Is there any way to tell if someone is logged on to the computer?

I have a program that runs as a service under Win2k/XP pro/Vista etc that needs to know if someone is logged on before it tries to launch a vb6 application that I want to run.  I realize I could start the vb6 application up in the startup menu, but need to tell the service program to be quiescent if the user logs off, so its best if the service program can tell if anyone is logged on else have it be quiet.

The service program was written in PowerBasic which has syntax that is very close to vb6. With a user logged on and the vb6 program running the service basically checks in with the vb6 program to see if its running correctly. If it gets stuck the service program closes it and/or restarts it. Because the vb6 program has some screens that display I don't want to attempt to start the vb6 program if no one is logged on.

Everything, so far is working great, but I need a way for the PowerBasic program to tell if someone is logged on. A solution written for Vb6 will translate easily to PowerBasic so the person answering can assume I'm writing my solution in vb6.

I found a sample project on line that uses NetUserGetInfo where I can tell if someone is logged on if I know their logon name in advance, but nothing where I can check if anyone is logged on. Any hints?

Thanks in advance.

Avatar of ryansoto
Flag of United States of America image

You can always check the security logs on the domain controller.  It generates an event everytime someone logs on or off.
Avatar of KenLevin


There is no domain controller in most cases when this app will be run. Sorry for my ignorance about domain controllers. I presume that means the network has a domain controller; the network is a peer to peer network and we're just worried about one workstation to make sure its logged on or not. The service needs to know if it can safely launch a vb6 app.
Ah.  Sorry, I dont program but thought I would chime in with a network solution :)
Good luck!
Avatar of EDDYKT
Flag of Canada image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. I didn't test this, but it makes sense and is a logical way to solve the problem. Thanks again. Ken