Solved

Record user logon and off date and times into a database

Posted on 2009-04-07
4
516 Views
Last Modified: 2012-05-06
Hi all.

Wondering if the above is posible. and if so how???

We have been using Group Policy to  log all users logon's and logoff's on our network.

This is only recording it into a txt file or csv file.  This really is not helping with a automated preview as the data is inserted differently. i,e, some PC's insert Logoff Username PCName Day Date Time, where as other only put in Logoff Username PCName Date Time (Leaving of the day) which i can nto automate...


I was wondering if there is anyway i can record this information without having to import it into a database.

I was wondering either Access or SQL. I was thinking along the lines of SQLCMD, but as far as i can see, unless i have it installed on every PC, it will not work.

Does any have any suggestions??

Baker
------So far----

rem ------logon.cmd----

echo logon %username% %computername% %date% %time% >> \\postmaster2\log\logon.log

echo logon %username% %computername% %date% %time% >> \\postmaster2\log\log_on.csv
 

rem -----logoff.cmd-----

echo logoff %username% %computername% %date% %time% >> \\postmaster2\log\logoff.log

echo logoff %username% %computername% %date% %time% >> \\postmaster2\log\log_off.csv

Open in new window

0
Comment
Question by:Bakersville
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:brittonv
ID: 24086730
Just to be sure, did you know that there is a built in auditing ability in Windows?
http://technet.microsoft.com/en-us/library/bb742436.aspx 
0
 
LVL 1

Author Comment

by:Bakersville
ID: 24086869
Thank you for that.

My issue is that i have to try and find the amount of time they are spending on their PC, so need to be able to pull this information into somewhere i can automaticlly generate reports.

This is why i was wondering if something like sqlcmd is worth a shot?
0
 
LVL 8

Accepted Solution

by:
brittonv earned 500 total points
ID: 24087224
To be honest I don't know if you can do it with sqlcmd.

Here is a script that shows the last logon.  Perhaps you could use a script that calculates the time logged on and puts that in your text file instead.
'<script language="vbscript">

OPTION EXPLICIT
 

DIM oNet, strComputerName, strUserName, strUserDomain

SET oNet = CreateObject("WScript.Network")

strComputerName = oNet.Computername

strUserName = oNet.UserName

strUserDomain = oNet.UserDomain

'msgbox strUserDomain

SET oNet = nothing
 
 

DIM oUser, strReturn

on error resume next

SET oUser = GetObject("WinNT://" & fnGetWorkgroupName(".") & "/" & strComputerName & "/" & strUserName & ",user")

strReturn = oUser.LastLogin

on error goto 0

SET oUser = nothing
 

IF isDate(strReturn) THEN

	strReturn = cdate(strReturn)

	strReturn = Replace(strReturn, ":" & Right(0 & Second(strReturn), 2) & " ", "")	'drop seconds

END IF
 
 

On Error Resume Next

	call WScript.Echo(strReturn)	'for cmd line

	call Echo(strReturn)	'for BGInfo

on error goto 0
 
 
 

' gets current workgroup

' params: computer name (can take "." for current computer instead)

' returns: string of computer's current workgroup

FUNCTION fnGetWorkgroupName(p_strComputer)

	DIM colItems, oItem

	Set colItems = GetObject("winmgmts:\\" & p_strComputer & "\root\cimv2").ExecQuery("Select * from Win32_ComputerSystem",,48)

	For Each oItem in colItems

		fnGetWorkgroupName = oItem.Domain

	Next

	SET colItems = nothing

END FUNCTION

Open in new window

0
 
LVL 1

Author Closing Comment

by:Bakersville
ID: 31567475
Thank you, this pointed me in the right firection
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Learn about cloud computing and its benefits for small business owners.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now