Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Im trying to write a script (vbs as i understand that better than powershell) that records time logged on times logged off username (possibly) and duration. First thoughts are is there a wmi variable somewhere that records when you logged on? then i could just read that and set a script to run at logout that uses current time etc then writes it to pcname.csv

 

idea is to try and get some idea how much pcs are being used if at all in the case of some laptops

Posted

If you're using VBScript you can do the following to get the user name, computer name and time logged on:

 

Dim wsShell, ComputerName, UserName, LogonDateTime
Set wsShell=CreateObject("Wscript.Shell")
ComputerName=wsShell.ExpandEnvironmentStrings("%ComputerName%")
UserName=wsShell.ExpandEnvironmentStrings("%UserName%")
LogonDateTime=now()

 

We do something very similar to what you're looking at. We just run a vbscript in a logon and logoff script to record user name, computer name and date/time into a text file. I can post the whole code if you're interested.

Posted
If you're using VBScript you can do the following to get the user name, computer name and time logged on:

 

Dim wsShell, ComputerName, UserName, LogonDateTime
Set wsShell=CreateObject("Wscript.Shell")
ComputerName=wsShell.ExpandEnvironmentStrings("%ComputerName%")
UserName=wsShell.ExpandEnvironmentStrings("%UserName%")
LogonDateTime=now()

 

We do something very similar to what you're looking at. We just run a vbscript in a logon and logoff script to record user name, computer name and date/time into a text file. I can post the whole code if you're interested.

 

please

the problem i see with that is that a logon/logoff script will create 2 lines in a text file so read like

 

pc01,fred,11:00,on

pc01,fred 11:10,off

 

rather than say pc01,fred,11:00,11:10,0:10

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...