How can I get the logged in users username on Win32?

Fredrik Lundh fredrik at pythonware.com
Wed Mar 14 11:27:35 EST 2001


"nomad" wrote:
> After searching through the Python Docs, I found that on Un*x I could
> use getpass.getuser(), but there is no equivalent for the Win32
> platform.
>
> In other words, how can I get the username in Windows?

in case you really meant to post this again, here
are the responses you got two weeks ago:

fredrik:
> > In other words, how can I get the username in Windows?
>
> getpass.getuser()
>
> (it works as long as USERNAME is set, which it usually is)

mark:
> And win32api.GetUserName() should work even if it isnt :)

Cheers /F





More information about the Python-list mailing list