Write a script which run on each user's PC on login, and will append the current date and time (on separate lines is easier) to a text file stored on the server. The text file's name will be the same as the user name of the current user. Write a script which the manager will use to retrive these dates and times. Set it up like a menu, where the manager has 2 options:
'1. Allow the manager to enter a user name, and have it tell them the dates and times that the particular user has logged in.
'2. Allow the manager to search for whether a user has logged in on a particular date.
'If so, give a MessageBox for each time the user logged in on that date (alternatively, give just one MessageBox which includes all the times for that particular day).

Dani AI

Generated

asked for two small VBScript tools: a logon script that appends the current date and time to a per-user file on a server, and a manager script that (1) shows all times for a username or (2) checks whether a user logged in on a specific date. While and kept things light, the practical approach below uses WScript.Network + Scripting.FileSystemObject, writes dates as YYYY-MM-DD and times as HH:MM:SS (one per line), and keeps parsing straightforward.

Client (logon) script — writes two lines per login (date then time). Replace \YOUR-SERVER\LoginLogs\ with the real UNC share and ensure users have write/create rights to that folder.

Const ForAppending = 8
Set wsh = CreateObject("WScript.Network")
username = wsh.UserName
logFolder = "\\YOUR-SERVER\LoginLogs\"
logFile = logFolder & username & ".txt"

Set fso = CreateObject("Scripting.FileSystemObject")
dt = Now
yyyy = Year(dt)
mm = Right("0" & Month(dt), 2)
dd = Right("0" & Day(dt), 2)
hh = Right("0" & Hour(dt), 2)
nn = Right("0" & Minute(dt), 2)
ss = Right("0" & Second(dt), 2)

Set f = fso.OpenTextFile(logFile, ForAppending, True)
f.WriteLine yyyy & "-" & mm & "-" & dd
f.WriteLine hh & ":" & nn & ":" & ss
f.Close

Manager script — simple menu with two options. It reads the same two-line-per-entry format and either dumps all entries or finds times for a given date.

Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
logFolder = "\\YOUR-SERVER\LoginLogs\"

choice = InputBox("1: Show all times for a user" & vbCrLf & "2: Search a user for YYYY-MM-DD", "Manager Menu")
' (then handle choice "1" and "2" by opening logFolder & username & ".txt", reading pairs of lines,
'  collecting results and using MsgBox to display either all entries or matching times)

Deployment & troubleshooting notes: run the writer as a Group Policy logon script (or equivalent) so the network share is available; ensure both share and NTFS permissions allow user write and manager read; prefer per-user files to reduce contention. If many simultaneous writes occur, consider centralized logging (DB or service) instead. If domain\user naming might be used, sanitize the filename (replace "\" with "-").

Recommended Answers

All 5 Replies

Soooo......

You Want Someone To Do Your Homework For You?

Soooo......

You Want Someone To Do Your Homework For You?

If i write the script, can i have his degree??

;) why not?

;) why not?

I'll need that in writing. . .

Hahaha, if I was professor maybe....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.