Windows 7 - check when PC was last logged onto a network

Asked By Tony Logan on 21-Sep-10 11:02 AM
Is there a way I can use VBScript to check when a particular PC was last
logged onto a given domain (our company network)?

Our site support staff would find this useful in getting some of our remote
users to connect more frequently for security patches, application updates,
etc., if there was a way to check how many days since the PC was last
connected to the network, then display a message to the user if number of
days not on the network is greater than X.


Pegasus [MVP] replied to Tony Logan on 21-Sep-10 04:55 PM
I do this by getting the logon script to maintain a log file on the server
for every user who logs on, recording the following details:
- Date, time
- User name
- Computer name
- Local or remote logon

This approach has several advantages:
- It tells you exactly who logs on where and when.
- It is controlled centrally. There is no need to launch a script locally.
- You do not need to rely on users responding to a message (they do not!).
You will know without asking them.
- The log file is a valuable source of information when you have security
concerns, e.g. log ons outside business hours, remote logons, logons on the
wrong workstation.
Al Dunbar replied to Pegasus [MVP] on 22-Sep-10 01:07 AM
I have been doing much the same for about 10 years, porting the script from
kixtart to vbscript when we migrated from w98 to xp. Unfortunately...

If the workstations and servers on your network are not well connected, you
might want to consider coding this so that the log file is kept on the
nearest server.

I agree with Pegasus' last bullet about this being a valuable source of
info. But if someone can reverse-engineer your script they might find ways
of falsifying the data stored in the log, or even using the information  for
their own ends.

I got around this (sort of) by running a scheduled task every hour that
moves the log file into a folder to which users have no access.