Jump to content

Recommended Posts

Posted
I wrote a couple of vbscripts that we set to run at logon and logoff. Basically they write a logon entry to a mySQL database when users logon, and then delete it when they logoff. It's then pretty simple to check who's logged on and where. I can post the scripts if anyone's interested?
Posted

@Kevin

 

It depends what you want to do. This what Plexer and Matt were hinting at:

set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "I am " & WshShell.ExpandEnvironmentStrings("%USERNAME%")

 

Alternatively if you talking about doing this remotely then you have to delve into WMI or just used psloggedon (from PSTools) with an appropriate grep filter.

Posted
I wrote a couple of vbscripts that we set to run at logon and logoff. Basically they write a logon entry to a mySQL database when users logon, and then delete it when they logoff. It's then pretty simple to check who's logged on and where. I can post the scripts if anyone's interested?

 

maybe a dumb question here but if you delete it after they log off then how do you check whose logged on if its deleted ie if you check the database after they have logged off and hence its been deleted ?

Posted
I wrote a couple of vbscripts that we set to run at logon and logoff. Basically they write a logon entry to a mySQL database when users logon, and then delete it when they logoff. It's then pretty simple to check who's logged on and where. I can post the scripts if anyone's interested?

 

maybe a dumb question here but if you delete it after they log off then how do you check whose logged on if its deleted ie if you check the database after they have logged off and hence its been deleted ?

 

Hey Shane.

 

I suppose because it's really about checking who is logged on and where, rather than *who was* logged on and where.

 

:?:

 

Paul

Posted

Hi thanks for the reply.

I was thinking more along the lines of if they go to our web server to do an internet survey. ( which i hate doing) it would just fill in their names e.g like what you get on xp start menu.

 

I was thinking that if i get this to work to use some sort of data base so that it would know if they have alrdy filled in the survey and just pass them on to our local intranet

Posted

I know this is real easy in asp so it must be just as easy in php.

 

This is a list of server variables you can request (which includes the username).

 

http://www.w3schools.com/asp/coll_servervariables.asp

 

This page is biased towards asp so this page looks like it show how to incoprorate it into php

 

http://www.developerfusion.co.uk/show/3703/5/

 

the LOGON_USER variable is probably most appropriate if it is going to be for machines on your network.

 

You will probably have to disable anonomous login on the file / folder in question so that it makes sure it fetches the page.

  • 4 weeks later...
Posted
Quick and dirty:

 

echo %username%>c:\name.txt

 

do you know how to do this for time and machine name too?

 

just been playing and can get it to do this by putting the below in a bach file all i need to do is get it to write to a database

 

echo %username% %computername% %date% %time%>c:\test.txt

Posted

AutoIT script which may help:

 

; AutoIt Version: 3.10

; Language: English

; Platform: WinXP

; Author: Matt Marsh

; Script Function: Script that records logon details in log file

; Date: Oct 2005

 

 

Dim $sLogPath = "c:\logs\logger.txt"

Dim $sLogMsg = "User: "

_FileWriteLog($sLogPath, $sLogMsg)

 

Func _FileWriteLog($sLogPath, $sLogMsg)

 

Local $sDateNow

Local $sTimeNow

Local $sMsg

Local $hOpenFile

Local $hWriteFile

Local $user

Local $cname

Local $ip

 

$sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY

$sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC

$user = @UserName

$cname = @ComputerName

$ip = @IPAddress1

 

$sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg & $user & " Logged On To PC: " & $cname & "," & " IP Address: " & $ip

 

$hOpenFile = FileOpen($sLogPath, 1)

 

If $hOpenFile = -1 Then

SetError(1)

Return 0

EndIf

 

$hWriteFile = FileWriteLine($hOpenFile, $sMsg)

 

If $hWriteFile = -1 Then

SetError(2)

Return 0

EndIf

 

FileClose($hOpenFile)

Return 1

EndFunc

 

Make a dir and file - c:\logs\logger.txt

Everytime this is run - [ you will need to compile it ], it will add a line to the txt file. This will record details for a local PC only.

Posted

VB would be something like this.

 

Set objNetwork = CreateObject("Wscript.Network") 

strUser = objNetwork.UserDomain & Chr(92) & objNetwork.UserName 

 

 

Which would give you domain\username

 

or

 

strUser = objNetwork.UserName

 

Which would give you just the username

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