This content has been marked as final. Show 3 replies
Well, have you tried working it through your extremely intelligent co-worker?
Sorry if that scared you away from answering, but I still haven't received any thoughts if anyone has some suggestions.
You can get the username of the last logged in user from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName then check if ntuser.dat for that userprofile is currently in use. If it is in use then a user is logged into the machine. If it is not in use then no user is logged into the machine.
here's a copy of the script.inc we have used in the past on NT machine to determine if a reboot should occur. It first checks if a user is currently logged in.
!- Set the userloggedon variable to 'no'
!- Get the username of the last user to log onto the machine
!- Check for the existence of the last user's NTUSER.DAT
!- If it is not there then no user is logged on and the profile has been deleted (per policy setting)
! - If the profile existst but NTUSER.DAT is not in use then the user is not logged in
! - The profile exists and NTUSER.DAT is in user. This means a user is logged in
!- This var is originally set to 'no' and then changed to 'yes' only if a user is logged on
! - Determine if the logged on user would like to reboot
MsgBoxEx('Do you want to reboot?','reboot','',mbYesNo)
! - If the user doesn't want to reboot then then clear any reboot flag and record the project as installed
!- In the event that no user is logged on or the user clicked 'Yes' to reboot the machine will now reboot