+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, script to record pc usage in Coding and Web Development; Im trying to write a script (vbs as i understand that better than powershell) that records time logged on times ...
  1. #1


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,916
    Thank Post
    231
    Thanked 899 Times in 774 Posts
    Rep Power
    303

    script to record pc usage

    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

  2. #2

    Join Date
    Oct 2005
    Posts
    62
    Thank Post
    7
    Thanked 20 Times in 17 Posts
    Rep Power
    22
    If you're using VBScript you can do the following to get the user name, computer name and time logged on:

    Code:
    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.

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,302
    Thank Post
    900
    Thanked 1,794 Times in 1,545 Posts
    Blog Entries
    12
    Rep Power
    465
    This will help - Who has logged on where?

  4. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,916
    Thank Post
    231
    Thanked 899 Times in 774 Posts
    Rep Power
    303
    Quote Originally Posted by PeterH View Post
    If you're using VBScript you can do the following to get the user name, computer name and time logged on:

    Code:
    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



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 3
    Last Post: 3rd November 2011, 07:51 PM
  2. Is it possible to record user usage on a Network
    By Adam728 in forum Network and Classroom Management
    Replies: 16
    Last Post: 11th March 2011, 10:55 AM
  3. Replies: 5
    Last Post: 14th June 2008, 01:18 AM
  4. Replies: 18
    Last Post: 14th October 2005, 10:28 AM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 08:45 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •