I use this function as a platform-independent way of finding out the current user name: def get_username(): if sys.platform == 'win32': return win32api.GetUserName() else: return getpass.getuser()