New project ( was Re: logging off windows users remotely wit

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:

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

You’d have something like this:

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)

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

From: Gordon T. [mailto:[email protected]] :

active_wmi

ar_wmi

wmi_rb

ruby-wmi

rWMI

wmi4r

me vote for ruby-wmi