Link to home
Start Free TrialLog in
Avatar of nickt25
nickt25Flag for Panama

asked on

report of login and logout of computer

hello expoerts i need to find the way
to know the first time that user login into their computer and when they log out.
the main idea of this is know at waht time the user star using his computer in the morning.


thanks guys
Avatar of Noduzz
Noduzz

My best recommendation is to create a login script to that logs that info either in a database remotely or log file on the machine or remote server.
ASKER CERTIFIED SOLUTION
Avatar of Noduzz
Noduzz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Don
I use the following two .bat

The first one is the logon script and the second is the logoff.

This creates a running excel spreadsheet that you can go back to anytime and view when users have logged on or off
@echo off
echo %username%,,%computername%,,%date%,, %time%,,logged off>>\\server1\logs$\logoffs.csv


ENDLOCAL

Open in new window

@echo off

set loc=
set GW=
Rem Determine whether the session is a local logon or a RDP session

netstat -an |find "3389" |find /I "established" >C:\Result1.txt
For /F "tokens=3 delims= " %%A IN (C:\Result1.txt) DO SET loc=%%A
if (%loc%)==() set loc=console



REM you could use this next routine to determine the subnet(Branch office location) by grabbing the default gateway
Rem You can modify GW= to fit your environment
Rem Modify IP's below to match your subnet gateways

for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find "Gateway"') DO SET GW=%%a
if %GW%== 10.63.106.2 set GW=Branch1    
if %GW%== 10.63.106.130 set GW=Branch2
if %GW%== 10.63.106.162 set GW=Branch3
if %GW%== 10.63.106.194 set GW=Branch4
if %GW%== 10.63.106.226 set GW=Branch5
if %GW%== 10.63.107.2 set GW=Branch6  
if %GW%== 10.63.107.34 set GW=Branch7
if %GW%== 10.63.107.66 set GW=Branch8
if %GW%== 10.63.107.98 set GW=Branch9
if %GW%== 10.63.107.130 set GW=Branch10
if %GW%== 10.63.107.162 set GW=Branch11
if %GW%== 10.63.107.194 set GW=Branch12   

REM this grabs the computer ip address


for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 "%computername%"') do set IP=%%i

Rem used double commas for readability
echo %username%,,%computername%,,%IP%,,%GW%,,%Loc%,,%Date:~0,16%,,%Time:~0,5%,,"logged on" >>\\server1\logs$\logins.csv 


ENDLOCAL

Open in new window

The second one is the logon script (they got switched around when I posted)
Avatar of nickt25

ASKER

tks :)