Solved

Record user logon and off date and times into a database

Posted on 2009-04-07
4
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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