WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check If Someone Is Logged In


Question:

I have a winbatch script that is run as a service. I need this script to wait until the user is actually logged into the computer before it does any of it's real work.

Basically the script finds the users ID from the Winlogon registry key, checks if AD is present and then determines if the user's password will expire in within 15 days. If the password will expire the user is told so and given a dialog box to change their password.

The problem is the scripts pulls this info at the login prompt and if the user should change their password at the login windows notified them to change their password), once they are in they get my notice even though they just changed their password.

The service is set to interact with the desktop. The dialog will wait until the desktop is present to put up the message but all of the work is done before a message is displayed.

More details:

This script was created for remote sales users that are not authenticating against a DC when they log on because they may not be connected to the network, as a result they do not get the message that their password is expiring. So I created the script (using lots of stuff I found in the tech database). The script is installed as a service that interacts with the the desktop and runs perfectly.

Lets say the users password will expire in 15 days. If the user's laptop is not connected to the network when they log in they are authenticating with cached info. The script looks for AD and if not found waits 10 minuted and tries again. When AD is found the script determines that the password will expire in 15 days (the threshold) and puts up dialog box asking the user to change their password.

The problem (more of a confusion) happens when the user IS connected to the network when logging in. Windows will tell them that their password will expire and asks them to change it. If they change their password, once the desktop come up the script will still display the dialog saying that the password has expired and the user is confused (because they just changed their password). This is because at the logon prompt it already foung AD and decided that the user's password is expiring, even before the user types in the password.

I need the script to wait until the user is logged in before checking password expiration.

Answer:

Try:
;Wait for user to be logged on
While WinExist("Program Manager") == @FALSE
   TimeDelay(2)
EndWhile
This seems to work, the service is able to see is program manager is there or not.
Article ID:   W16990
File Created: 2007:07:03:14:27:30
Last Updated: 2007:07:03:14:27:30