+ 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
    275
    Blog Entries
    4
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    12

    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. IDG Tech News

  3. #2

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    9,564
    Thank Post
    306
    Thanked 884 Times in 794 Posts
    Rep Power
    211

    Re: Logged on

    %username% is the environment variable for it.

    Ben

  4. #3

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    8,472
    Thank Post
    889
    Thanked 890 Times in 532 Posts
    Rep Power
    596

    Re: Logged on

    Quick and dirty:

    echo %username%>c:\name.txt

  5. #4
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Morecambe, Lancashire, UK.
    Posts
    281
    Thank Post
    37
    Thanked 33 Times in 26 Posts
    Rep Power
    18

    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?

  6. #5

    Join Date
    Feb 2006
    Posts
    1,193
    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.

  7. #6
    wesleyw's Avatar
    Join Date
    Dec 2005
    Location
    Walsall
    Posts
    2,050
    Blog Entries
    1
    Thank Post
    207
    Thanked 49 Times in 43 Posts
    Rep Power
    26

    Re: Logged on

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

    Wes

  8. #7

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,027
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209

    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 ?

  9. #8

    Join Date
    Jul 2005
    Location
    Corby
    Posts
    1,057
    Thank Post
    12
    Thanked 19 Times in 17 Posts
    Rep Power
    19

    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

  10. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,027
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209

    Re: Logged on

    fair point lol, like i said, stupid question

  11. #10
    kevin_lane's Avatar
    Join Date
    Mar 2007
    Location
    Derby
    Posts
    275
    Blog Entries
    4
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    12

    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

  12. #11
    limbo's Avatar
    Join Date
    Aug 2005
    Location
    Birmingham
    Posts
    450
    Thank Post
    2
    Thanked 36 Times in 31 Posts
    Rep Power
    20

    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.

  13. #12
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,027
    Thank Post
    105
    Thanked 35 Times in 30 Posts
    Rep Power
    22

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

  14. #13

    Join Date
    Mar 2007
    Posts
    1,318
    Thank Post
    52
    Thanked 153 Times in 142 Posts
    Rep Power
    38

    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?

  15. #14
    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,056
    Blog Entries
    1
    Thank Post
    104
    Thanked 439 Times in 380 Posts
    Rep Power
    114

    Re: Logged on

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

  16. #15
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,027
    Thank Post
    105
    Thanked 35 Times in 30 Posts
    Rep Power
    22

    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 Networks
    Replies: 5
    Last Post: 6th December 2006, 10: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
  •