From: Daniel Berger Date: 2007-10-22T06:38:07+09:00 Subject: Re: Windows - Get current logged user Rodrigo Bermejo wrote: > James Tucker wrote: >> def get_user; ENV['USERNAME']; end > > The issue here is that it will return the username Im using to log into > the box > using net/telnet. > > Iam looking for the username of the guy seated in front of the computer. > Something similar to the UNIX 'finger,who,w' commands > > I've already tried looking in the registry with out success. require 'windows/system_info' include Windows::SystemInfo buffer = 0.chr * 256 nsize = [buffer.size].pack("L") unless GetUserName.call(buffer, nsize) raise 'Something went wrong' end length = nsize.unpack("L")[0] username = buffer[0 ... length].chop username Regards, Dan