System Process : Get currently logged on user?

Run app as system process but still get logged-on user

Page 1 of 1

5 Replies - 4005 Views - Last Post: 14 October 2010 - 08:16 PM Rate Topic: -----

#1 kercher  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 10-October 10

System Process : Get currently logged on user?

Posted 14 October 2010 - 03:09 AM

We have a small windows application that we need to run as a system process. However, somewhere in the application code, we need to get the login ID of the currently logged on user.

If we use the GetUserName function, it will return SYSTEM since this is running as a system application. So, is there a way for an application running as a system process to get the login ID / username of the currently logged-on user? :helpsmilie:

Is This A Good Question/Topic? 0
  • +

Replies To: System Process : Get currently logged on user?

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,066
  • Joined: 10-May 07

Re: System Process : Get currently logged on user?

Posted 14 October 2010 - 03:13 AM

You can use the Windows API function GetUserName()
Was This Post Helpful? 0
  • +
  • -

#3 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: System Process : Get currently logged on user?

Posted 14 October 2010 - 06:13 AM

View Postkercher, on 14 October 2010 - 04:09 AM, said:

We have a small windows application that we need to run as a system process. However, somewhere in the application code, we need to get the login ID of the currently logged on user.

If we use the GetUserName function, it will return SYSTEM since this is running as a system application. So, is there a way for an application running as a system process to get the login ID / username of the currently logged-on user? :helpsmilie:


Debug.Print Environ("UserName")



Research the Environ function, very useful. :)
Was This Post Helpful? 0
  • +
  • -

#4 kercher  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 10-October 10

Re: System Process : Get currently logged on user?

Posted 14 October 2010 - 07:53 PM

Environ("UserName") return blank when the application is run as a system process :dontgetit:
Was This Post Helpful? 1
  • +
  • -

#5 kercher  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 10-October 10

Re: System Process : Get currently logged on user?

Posted 14 October 2010 - 08:16 PM

View Postno2pencil, on 14 October 2010 - 02:13 AM, said:

You can use the Windows API function GetUserName()


Quote

If we use the GetUserName function, it will return SYSTEM since this is running as a system application.


we do use the GetUserName function but it returns the login name of the user that the application is running as, not necessarily the currently logged-in user :dontgetit:
Was This Post Helpful? 0
  • +
  • -

#6 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: System Process : Get currently logged on user?

Posted 14 October 2010 - 08:16 PM

View Postkercher, on 14 October 2010 - 08:53 PM, said:

Environ("UserName") return blank when the application is run as a system process :dontgetit:


I learn something every day :) ... in that case to be honest...idk...sorry :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1