finding out console user (Win95)

Dale Nagata dnagata at creo.com
Sat Nov 13 17:14:46 EST 1999


Radovan Garabik wrote:
> 
> I am porting my script from unix to windows, and I need to find
> console user under win95 (under WinNT I can use os.environ['USERNAME'],
> which is not exactly console user, but good enough for me).
> Something like cuserid() or getlogin() as implemented in
> Cygwin would be ideal....
> Is there a simple way to find it?
> 

The following should work on both Win95 and NT:

	import win32api
	print win32api.GetUserName()

This will get the correct account name even if the USERNAME
environment variable is set to something different.


--
Dale Nagata         |  tel : +1 604.451.2700 ext. 2254 (UTC-0800)
Software Developer  |  fax : +1 604.437.9891 
Creo Products Inc.  |  pgr : +1 604.691.8279
Burnaby BC Canada   |  http://www.creo.com/




More information about the Python-list mailing list