Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Profile log in record

19 Apr 2012   #11

MS Windows 7 Ultimate SP1 64-bit


My System SpecsSystem Spec
19 Apr 2012   #12

Windows 7

Ok. More of the right kind of info. It does not clearly state which user logged on. I am reading this correct? My account name is not mentioned there. Thx

Attached Files
File Type: txt event since clear logs.txt (55.3 KB, 10 views)
My System SpecsSystem Spec
19 Apr 2012   #13

Windows 7

I will create a socond user on my laptop, then do more tests
My System SpecsSystem Spec

19 Apr 2012   #14

Windows 7

Ok. Positive progress. Created a new user. Logged on. Logged off. Logged in with current account. I see that in the txt file and also a lot of other info. Way too much... How do I extract only the log/off events. Thank you

Attached Files
File Type: txt last hour.txt (68.4 KB, 23 views)
My System SpecsSystem Spec
19 Apr 2012   #15

Windows 10 Pro X64

What/how are you creating the file? Are you using PsLogList or a different tool? You're going to need some way to parse the output to extract just the info you want. Powershell will do this but I have no experience with it. Might be able to do it with a batch file but it would take a fair amount of trial and error to get it working.

Hopefully someone else (karlsnooks?) will have a suggestion.
My System SpecsSystem Spec
19 Apr 2012   #16

MS Windows 7 Ultimate SP1 64-bit

To produce a list of all users with their log on times and their log off times turns out to be non-trivial.

I can give you a script showing the last loon times with the user name, but for reasons that I do not understand the last logoff time is not there, i.e., not a valid string.

Otherwise, I'd recommend visiting some of the powershell forums and posing you question there.
My System SpecsSystem Spec
20 Apr 2012   #17

Windows 7

Thx. Not sure what "loon times" mean. I suspect typeO. That script would be just great. As I understand it... (as my client has explained) he wants to know who was logged on at the time that a certain change was made. The grow fresh produce in huge green houses. They pack for our local market and international. The software controlles heating, venting, water, tempratures and around 70 more variables. It so happend that they lost a crop the other day due to too much water. Now measures needs to be put in place to prevent that event again. Offcourse, no-one would take responsability for the change. If he had a way to pinpoint the user that was logged on at the time it gives him a good place to start.

I do thank you for your efforts
My System SpecsSystem Spec
20 Apr 2012   #18

Windows 7 Ultimate x64

Quote   Quote: Originally Posted by Ztruker View Post
Found this: How do I view login history for my PC using Windows 7

The best way is to create a logon/logoff script that is run when each user does either. It can record the logon/logoff info in a file somewhere.
I agree the easiest way would be to use a logon & logoff script via Group Policy to create a log file. I would then recommend setting permissions on the log file to prevent anyone from changing it to cover there tracks although I not sure what permissions will allow or prevent the scripts from working.

I created a basic batch file using a reference from the link in the quote. Copy the code below to a batch file.
@echo off
if not exist c:\Logs md c:\Logs

echo Logon: %date%   %time:~0,5%   %UserName%>> c:\Logs\HistoryBasic.txt

echo Logon,"%date:~0,3%, %date:~4,2%/%date:~7,2%/%date:~10,4%",%time:~0,5%,%UserName%>> c:\Logs\History.csv
echo Logon: %date:~0,3%, %date:~4,2%/%date:~7,2%/%date:~10,4%   %time:~0,5%   %UserName%>> c:\Logs\History.txt
You actually only need one of the lines starting with "echo" but I have given 2 examples of different formatting and 1 that outputs to a CSV file (Comma Delimited) for use with a spreadsheet application. Check the attached image for a preview.

This is the logon script, for the logoff script change logon to logoff and save as 2 seperate files.

If you would like different formatting and don't know how to change it I can also help with that.

On WinXP I'm not sure if PowerShell was an optional update or would have been auto installed so you might want to check that before continuing with PowerShell scripts, although it's easy to install.

Still post your script.

EDIT: Modified the code above because I had it set to echo the full name of the day as you can see in my screenshot but just found out it doesn't work to well for Saturday because the short version of it is Sat so it logs as Satday. Only Sunday, Monday and Friday will work.

History.txt and HistoryBasic.txt are now the same except a comma after the day.

If you would like it to read Saturday, Sunday etc.. then I could work some if statements in there to check what the day is first and set a variable to echo instead.

Attached Images
Profile log in record-logon-off_history.jpg 
My System SpecsSystem Spec
20 Apr 2012   #19

MS Windows 7 Ultimate SP1 64-bit

why I thank you for giving me permission to post my script.
My System SpecsSystem Spec
20 Apr 2012   #20

MS Windows 7 Ultimate SP1 64-bit


# run PowerShell as an ADMINISTRATOR

# Simply copy and paste (You paste into PowerShell by clicking on right mouse button
# You can delete all of these lines which start with a # aforehand if desired

# a period indicates this computer, use actual name if desired
# $data defined as empty array
# match will compare against a 'regular' expression
# if match exist, returns true, result placed in $matches array

$a = "."
$data = @()
$NetLogs = Get-WmiObject Win32_NetworkLoginProfile -ComputerName $a

foreach ($NetLog in $NetLogs) {
if ($NetLog.LastLogon -match "(\d{14})") {
$row = "" | Select Name,LogonTime,numberoflogons
$row.Name = $NetLog.Name
$row.numberoflogons = $netlog.numberoflogons
$row.LogonTime=[datetime]::ParseExact($matches[0], "yyyyMMddHHmmss", $null)
$data += $row

#end of script
My System SpecsSystem Spec

 Profile log in record

Thread Tools

Similar help and support threads
Thread Forum
The User Profile Service failed the logon. Safe mode, only my profile
Hi After experiencing some blue screens (graphics driver related) I reverted back to 314.22 and this morning decided to give the card a good clean. This is my main PC which has Windows 7 Home Premium, Q9450, GTX 260 (216). Somehow I managed to corrupt my user profile and received the User...
General Discussion
Instead of logging into main profile, I am forced into temp profile
When attempting to login to my main profile, after a several minute wait, Windows loads normally, but I receive a notice saying that I have been logged into a temporary profile, which would be deleted upon shutting down. As far as I can tell, this started happening immediately after switching...
General Discussion
Big Mess after creating new profile and deleting original profile
Originally I had all my data files in drive D and only programs in drive C. Somehow my old user profile got corrupted and the Backgound wall paper is not working properly. So I created a new admin profile to fix it but now I have a mess . After I created a new admin profile and moved the old...
General Discussion
HELP! User profile service failed the login - profile cannot be loaded
I followed the tutorial here and it worked beautifully... All my user docs are on the D drive and the Start button entires all point to the new location. HOWEVER when I tried to log in this mornias wand was...
Backup and Restore
Record Icon not showing when pressing record in Live TV
Hi Guys When I am watching Live TV and press the record button on my remote or through the interface using the mouse I am no longer getting the red icon indicating that recording has started but the program is actually recording. I use to get it but for some reason it now no longer pops up. Has...
Media Center

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 13:44.
Twitter Facebook Google+