Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Record user logon and off date and times into a database

Posted on 2009-04-07
4
Medium Priority
?
530 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

916 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