+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Scripts Thread, Logged on in Coding and Web Development; How do i get a some ones login user name for when they have logged on i need to get ...
  1. #1
    kevin_lane's Avatar
    Join Date
    Mar 2007
    Location
    Derby
    Posts
    505
    Thank Post
    23
    Thanked 20 Times in 20 Posts
    Blog Entries
    5
    Rep Power
    19

    Logged on

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

  2. #2

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,325
    Thank Post
    622
    Thanked 1,577 Times in 1,414 Posts
    Rep Power
    413

    Re: Logged on

    %username% is the environment variable for it.

    Ben

  3. #3

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    Re: Logged on

    Quick and dirty:

    echo %username%>c:\name.txt

  4. #4
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Morecambe, Lancashire, UK.
    Posts
    281
    Thank Post
    39
    Thanked 36 Times in 26 Posts
    Rep Power
    25

    Re: Logged on

    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?

  5. #5

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Logged on

    @Kevin

    It depends what you want to do. This what Plexer and Matt were hinting at:
    Code:
    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.

  6. #6
    wesleyw's Avatar
    Join Date
    Dec 2005
    Location
    Kingswinford
    Posts
    2,205
    Thank Post
    223
    Thanked 50 Times in 44 Posts
    Blog Entries
    1
    Rep Power
    30

    Re: Logged on

    @altecsole : Could be interesting to see how you've done that?

    Wes

  7. #7

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,703
    Thank Post
    3,235
    Thanked 1,043 Times in 965 Posts
    Rep Power
    363

    Re: Logged on

    Quote Originally Posted by altecsole
    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 ?

  8. #8

    Join Date
    Jul 2005
    Location
    Corby
    Posts
    1,056
    Thank Post
    12
    Thanked 20 Times in 18 Posts
    Rep Power
    24

    Re: Logged on

    Quote Originally Posted by gecko
    Quote Originally Posted by altecsole
    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

  9. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,703
    Thank Post
    3,235
    Thanked 1,043 Times in 965 Posts
    Rep Power
    363

    Re: Logged on

    fair point lol, like i said, stupid question

  10. #10
    kevin_lane's Avatar
    Join Date
    Mar 2007
    Location
    Derby
    Posts
    505
    Thank Post
    23
    Thanked 20 Times in 20 Posts
    Blog Entries
    5
    Rep Power
    19

    Re: Logged on

    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

  11. #11
    limbo's Avatar
    Join Date
    Aug 2005
    Location
    Birmingham
    Posts
    460
    Thank Post
    2
    Thanked 41 Times in 36 Posts
    Rep Power
    25

    Re: Logged on

    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.

  12. #12
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,152
    Thank Post
    130
    Thanked 54 Times in 47 Posts
    Rep Power
    38

    Re: Logged on

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

  13. #13

    Join Date
    Mar 2007
    Posts
    1,750
    Thank Post
    79
    Thanked 288 Times in 219 Posts
    Rep Power
    70

    Re: Logged on

    Quote Originally Posted by mattx
    Quick and dirty:

    echo %username%>c:\name.txt
    do you know how to do this for time and machine name too?

  14. #14

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Logged on

    Time:
    Code:
    Time /T > time.txt
    Machine name:
    Code:
    echo %COMPUTERNAME% > pcname.txt

  15. #15
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,152
    Thank Post
    130
    Thanked 54 Times in 47 Posts
    Rep Power
    38

    Re: Logged on

    Quote Originally Posted by strawberry
    Quote Originally Posted by mattx
    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

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Who is (logged) on..
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 5th August 2007, 12:06 PM
  2. Logged on
    By kevin_lane in forum Scripts
    Replies: 0
    Last Post: 8th May 2007, 01:55 PM
  3. Seeing who is logged on
    By faza in forum Wireless Networks
    Replies: 5
    Last Post: 6th December 2006, 09:19 AM
  4. Who last logged on
    By danIT in forum Windows
    Replies: 1
    Last Post: 2nd October 2006, 09:08 AM

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
  •