[python-win32] User login details when running a service

2020-04-11 Thread Waseem Afser
Is there any possible method to get the logged in user's username from a
windows service ?

FYI: getpass.getuser() and other similar methods return the computer name
instead of the username of the user when the script runs as a service.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] User login details when running a service

2020-04-11 Thread Tim Roberts
On Apr 11, 2020, at 6:32 AM, Waseem Afser  wrote:
> 
> Is there any possible method to get the logged in user's username from a 
> windows service ? 

Your assumption that there is only one "logged in user” is false, which is why 
the information you seek is not readily available.

There is a WMI query that can return the name of all logged in users:

https://stackoverflow.com/questions/5218778/how-do-i-get-the-currently-logged-username-from-a-windows-service-in-net
 

— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32