Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.
Thanks
MC
···
--
Posted via http://www.ruby-forum.com/.
Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.
Thanks
MC
--
Posted via http://www.ruby-forum.com/.
May not be pretty, but you can always do
username=%x[echo %USERNAME%].strip
A decent sized list of windows environmental variables is here:
http://vlaurie.com/computers2/Articles/environment.htm
That said I think there _is_ s nice builtin way of accessing windows
environmental variables in ruby, but it's been so long I'd probably
just shell out using %x
On Fri, Apr 17, 2009 at 11:08 AM, Mmcolli00 Mom <mmc_collins@yahoo.com> wrote:
Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.Thanks
MC
--
Posted via http://www.ruby-forum.com/\.
I don't know of a way. You could look at the Ruby on Windows blog [
http://rubyonwindows.blogspot.com/ ] or search Google while waiting for
others to reply.
Regards,
Craig
--
Craig Demyanovich
Mutually Human Software
On Fri, Apr 17, 2009 at 10:08 AM, Mmcolli00 Mom <mmc_collins@yahoo.com>wrote:
Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.Thanks
MC
--
Posted via http://www.ruby-forum.com/\.
--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can’t hear a word you’re saying."
-Greg Graffin (Bad Religion)
Mmcolli00 Mom wrote:
Do you know if there is a way to get the Windows OS Login name using
Ruby? I can do this with VB but haven't found a way to do this in Ruby.
require 'etc'
p Etc.getlogin
# OR
gem install sys-admin
require 'sys/admin'
p Sys::Admin.get_login
Regards,
Dan
That said I think there _is_ s nice builtin way of accessing windows
.sub!(" s "," a ")
May not be pretty, but you can always do
username=%x[echo %USERNAME%].strip
[...]
That said I think there _is_ s nice builtin way of accessing windows
environmental variables in ruby, but it's been so long I'd probably
just shell out using %x
ENV['USERNAME']
Was that so hard? Or does that not work on Windows?
On Friday 17 April 2009 11:12:27 Kyle Schmitt wrote:
Wow, funny enouhg, I don't recall using ENV before. Nice.
And I just verified on a windows box, yea that does work.