Laurie Kennedy
asked on
Script to Display Last Login time
Hello,
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.
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
Dim User
Dim UserName
Dim UserDomain
Dim WshNetwork
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is not a VBScript... it's a batch script. Just rename the attached file to LOGONTIME.CMD and put it in your startup folder.
ASKER
Doh! This will handle multiple users logging into the same terminal server, correct? It looks like it.
Absolutely it will.
ASKER
Windows Script Host
Line: 3
Char: 12
Error: Expected '='
Code: 800A0F3
Source: Microsoft VBScript compilation error