#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    India
    Posts
    9
    Rep Power
    0

    getting username while running as a service


    is there a way to get logged-in username while running as a
    service...NetWkstaUserGetInfo() crashes the program when
    run as a service though it worked fine in stand alone...is there
    any other way...plssss help :(...

    i also tried to get it from system environment but it seems that
    when a program is run as a service then variables like
    %username% are not set...or am i wrong??...

    thanks...
    Amit...
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    India
    Posts
    9
    Rep Power
    0

    Lightbulb


    okkk...i managed to do it in a different way...gave system
    "tasklist" command & got the info about explorer.exe...copied it
    into a file & read username from that info...

    the only catch was when there r several users at the same
    time (using switch user) but it was easy to take care of by a
    small trick...

    Amit...

    [dont know if tasklist is available on windows other than XP]

IMN logo majestic logo threadwatch logo seochat tools logo