Finding out the username of the current user on Windows in Haskell?

I hope I have not missed the obvious answer to this somewhere, but in case I have, I apologize.

System.Posix.User has a getLoginName function to find the login for the current user. Now, what will work to get the same information on Windows platforms?

+7
windows haskell
source share
1 answer

As the USERNAME environment variable contains the name of the user who is currently logged into Windows, you can use this to find out the user name:

 import System.Environment main = getEnv "USERNAME" >>= print 
+7
source share

All Articles