We have a few windows 2003 terminal servers on a windows 2003 domain. We want either a software widget or some way that will display a pop up for users when they log on that shows when the last time they logged in. We were given the following script which will run and display the last login time. Here is the problem. If we put this script in the startup folder, they have to log into the terminal server to get the script to run so it will tell them there last login time was a few seconds ago (which is correct, but not what we need). I dont know if there is a way to display the 2nd to last login or a better way to run the script, but any help would be appreciated. Script is attached. Thanks.
On Error Resume Next
Set WshNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
UserDomain = objDomain.Get("dnsHostName")
UserName = WshNetwork.UserName
Set User = GetObject("WinNT://" & UserDomain & "/" & UserName & ",user")
MsgBox "The last time " & UserName & " logged on was: " & vbCRLf & vbCRLf & User.LastLogin