Solved

Log Total Logon Time

Posted on 2008-10-29
3
216 Views
Last Modified: 2010-04-21
I worked out a deal with my boys where they need to give me an hour of reading for every hour of computer game time.  I'm running Windows Server 2003 at home, and both boys have a domain account.  Is there a Group Policy, a domain account property, or a script  that enables me to log their time logged on?  Ideally, I'd like to push the data into SQL Server (where I keep everything else), but a simple log file will work fine as well.
0
Comment
Question by:jdana
3 Comments
 
LVL 13

Accepted Solution

by:
Brum07 earned 125 total points
ID: 22833506
You could run a logon and then log off script (as below) this records the following

Time
Date
User
NetBIOS Name
OU & Domain
Make/Model
Serial Number

You could then calculate from the two times how long a user was on the system

Dim objWMI : Set objWMI = GetObject("winmgmts:")

Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")

Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")

Dim objComputer, strModel, strSerial

For Each objComputer in colSettings

  strModel = objComputer.Model

Next

For Each objComputer in colSettingsBios

  strSerial = objComputer.SerialNumber

Next

'INSERT LOG FILE PATH HERE

sLogFilePath = "C:\log.csv"

sType = "Logon"

Const OpenAsASCII = 0

Const OverwriteIfExist = -1

Const ForAppending = 8

Set oShell = CreateObject("WScript.Shell")

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oWshNetwork = CreateObject("WScript.Network")

Set oADSystemInfo = CreateObject("ADSystemInfo")

sDate = date

sTime = time

sComputer = oWshNetwork.ComputerName

sUser = oWshNetwork.UserName

Set oUser = GetObject("LDAP://" & oADSystemInfo.UserName)

sUserOU = Mid(oUser.Parent, 8)

sLogLine = """" & sType & """,""" & sDate & """,""" & sTime & """,""" & sUser _

& """,""" & sComputer & """,""" & sUserOU & """,""" & strModel & """,""" & strSerial & """"

If oFSO.FolderExists(oFSO.GetParentFolderName(sLogFilePath)) Then

bUpdLogFinished = False

iLoops = 0

On Error Resume Next

Do

Err.Clear

Set fLogFile = oFSO.OpenTextFile(sLogFilePath, ForAppending, True)

If Err.Number <> 0 Then

WScript.Sleep 500

Else

fLogFile.WriteLine sLogLine

fLogFile.Close

bUpdLogFinished = True

End If

iLoops = iLoops + 1

Loop Until bUpdLogFinished Or iLoops > 10

On Error Goto 0

End If

Open in new window

0
 
LVL 26

Assisted Solution

by:farhankazi
farhankazi earned 125 total points
ID: 22833602
Have a look at following link:
http://www.rlmueller.net/Logon5.htm

Hope this helps!
Farhan
0
 

Author Closing Comment

by:jdana
ID: 31511287
Thanks guys.  These are perfect!  Maybe I'll customize the scripts a little and practice my VBS skills (which stink).
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

Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

911 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

19 Experts available now in Live!

Get 1:1 Help Now