[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

new project ( was Re: logging off windows users remotely with ruby

gordon

6/1/2007 10:08:00 PM

> > > Any help? I know it can be done with vbscript and wmi, but I really
> > > really want to accomplish this using some ruby as I am trying to
> > > introduce more of it in our company
> > >
> Additionally you can use WMI through Win32OLE, and issue the commands that way.

I've been playing around with a library that would provide an activerecord style interface to WMI. So, instead of this:

<code>
require 'win32ole'

LOGOFF = 0

computer_name = 'host'
wmi = WIN32OLE.connect("winmgmts:\\\\#{computer_name}\\root\\cimv2")
list = wmi.execquery("Select * from Win32_OperatingSystem",nil,48)

list.each do |item|
item.win32Shutdown(LOGOFF)
end
</code>

You'd have something like this:

<code>
require 'wmi' # or whatever it's going to be called

LOGOFF = 0

computer_name = 'host'
os = WMI::Win32_OperatingSystem.new(computer_name)

host = os.find(:first, :condition => {:primary => true})
host.win32shutdown(LOGOFF)
</code>

My aim is to have an easier to read, more rubyesque way to work with WMI. I've been thinking about opening a rubyforge project if there's any interest. But I don't know what to call the thing. Here is a list of names I've come up with. I don't really like any of them, though, so I'm open to other suggestions.

active_wmi
ar_wmi
wmi_rb
ruby-wmi
rWMI
wmi4r

Thanks,

Gordon




1 Answer

Peña, Botp

6/2/2007 12:49:00 AM

0

From: Gordon Thiesfeld [mailto:gthiesfeld@sbcglobal.net] :
# active_wmi
# ar_wmi
# wmi_rb
# ruby-wmi
# rWMI
# wmi4r

me vote for ruby-wmi