I have a scheduled maintenance script that runs as a service account. It runs at logon and every hour. I would like it to know who the logged-in user is on the workstation. Anybody have a good way to do this???

My current method is for the logon script to simply do a writeprofilestring("userinfo.ini","UserInfo","UserID",@USERID) to a known location and then have the maintenance script pick this up. But I have some timing issues at logon where the maintenance script is firing off faster than the user's logon script and picking up the PREVIOUS logged in user.

I'm thinking I need a different way of doing this. I seem to remember some command (maybe in the resource kit) which will list all the terminal and console login sessions. I could parse this I thought.

Ideas?