Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out username of the current user in Windows in Haskell?

I hope I have not missed an obvious answer to this somewhere, but in case I have - I apologise.

System.Posix.User feature a getLoginName for finding the login name of the currently logged in user. Now, what would work for getting the same information on the Windows platforms?

like image 358
Fredrik Karlsson Avatar asked Sep 16 '14 08:09

Fredrik Karlsson


1 Answers

As USERNAME environment variable contains the name of the user currently logged on in a windows system, you can use that to find out the username:

import System.Environment

main = getEnv "USERNAME" >>= print
like image 143
Sibi Avatar answered Oct 22 '22 13:10

Sibi