From: Luis Lavena Date: 2008-08-15T08:47:28+09:00 Subject: Re: How to get Windows user name? On Aug 15, 12:50 am, Mike Johnson wrote: > Hi, all > > I am trying to detect the user who's currently login the Windows system. > Is there way to do it in Ruby? > > Thanks NT/2K/2K3/Vista systems have a environment variable for interactive users: irb(main):001:0> ENV['USERNAME'] => "Luis" So you only need to asign ENV['USERNAME'] and will get the current username. If your process is not an interactive one (ala, a Windows service) then this variable will be nil or the special account used for it (LocalService). HTH, -- Luis Lavena