Hi
I think the next script is what you are looking
The script is for logon only. For logoff wou must change “Logon” with “Logoff”
‘***************************************************************************
‘* Script Name: logon.vbs
‘* Author: Ciprian Ionut Lozonschi
‘* Created on: 26.11.2003
‘* Description: record into a dastabase (SQL Server) users logons
‘* History:
‘* Operating System (Supported Platforms): XP, 2k3
‘* URL:
‘***************************************************************************
‘On Error Resume Next
Set objNet = WScript.CreateObject(“WScript.Network”)
‘connect to MS SQL Server
Set oConn= WScript.CreateObject(“ADODB.Connection”)
oConn.Open = “Provider = SQLOLEDB.1; Password = password;” & _
“Persist Security Info = True; User ID = userid;” & _
“Initial Catalog = DBName; Data Source = DBServerName;” & _
“Network Library = dbmssocn”
‘Password = SQL user password
‘User ID = SQL user id
‘Initial Catalog = SQL database name
‘Data Source = SQL Server name or IP
sqlIns = “insert into LogUsers (TipConexiune, UserName, ComputerName) values (‘Logon’, ‘” & objNet.UserName & _
“‘,'” & objNet.ComputerName & “‘)”
oConn.Execute = sqlIns
WScript.Quit
For the script to work you must have a database, in my case is a MS SQL DB Server (you could also record this in a access database, but you must change string connection – oConn) with a table, in my case named LogUsers with 4 fields: TipConexiune, UserName, ComputerName, Date (type Date with default value “getdate()”).
The script you must put to execute when a user logon (Group Policy – User ConfigurationWindows Settings – Logon)
Discuss This Question: 4  Replies