From a Windows XP command line, how do I get the time I logged into and/or out of the current machine? I'm looking for something like the UNIX last command which lists active and previous login sessions.
You could also query the logon time from WMI via a script:
As far as prior logons go, you're going to be stuck parsing the event log, assuming that you had auditing of successful logons enabled.
Event 528 from source "Security" is logged in the "Security" event log each time there's a successful logon. Logons with a "Logon Type" of "2" are interactive logons at the console.
Event 538 from source "Security" is logged in the "Security" event log when the user logoff occurs. You'll have to match the "Logon ID" from the logon event with the logoff event in order to compute times.
You can also just type in query user from an XP Command prompt. As far as previous logins you will have to have had auditing enabled in order to query the event log