How do i get a some ones login user name for when they have logged on i need to get it using either vb or php any ideas ? :?
How do i get a some ones login user name for when they have logged on i need to get it using either vb or php any ideas ? :?

%username% is the environment variable for it.
Ben
Quick and dirty:
echo %username%>c:\name.txt
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?
@Kevin
It depends what you want to do. This what Plexer and Matt were hinting at:
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.Code:set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo "I am " & WshShell.ExpandEnvironmentStrings("%USERNAME%")
@altecsole : Could be interesting to see how you've done that?
Wes
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 ?Originally Posted by altecsole
Hey Shane.Originally Posted by gecko
I suppose because it's really about checking who is logged on and where, rather than *who was* logged on and where.
:?:
Paul
fair point lol, like i said, stupid question
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
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.
I have now been asked to do this. However they want it to write to a central database rather than one per machine!! Is this possible??
do you know how to do this for time and machine name too?Originally Posted by mattx
Time:
Machine name:Code:Time /T > time.txt
Code:echo %COMPUTERNAME% > pcname.txt
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 databaseOriginally Posted by strawberry
echo %username% %computername% %date% %time%>c:\test.txt
There are currently 1 users browsing this thread. (0 members and 1 guests)