# New project ( was Re: logging off windows users remotely with ruby)

**URL:** <https://rubytalk.org/t/new-project-was-re-logging-off-windows-users-remotely-with-ruby/38033>\
**Category:** ruby-talk\
**Created:** [1 June 2007 22:07 UTC](https://rubytalk.org/t/new-project-was-re-logging-off-windows-users-remotely-with-ruby/38033 "2007-06-01T22:07:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Thiesfeld1](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@Gordon\_Thiesfeld1](https://rubytalk.org/u/Gordon_Thiesfeld1)\
**Post date:** [1 June 2007 22:07 UTC](https://rubytalk.org/t/new-project-was-re-logging-off-windows-users-remotely-with-ruby/38033/1 "2007-06-01T22:07:58Z")

</div>

> \> \> 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|  
&nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![\_Pena\_Botp1](https://avatars.discourse-cdn.com/v4/letter/_/94ad74/32.png) [@\_Pena\_Botp1](https://rubytalk.org/u/_Pena_Botp1)\
**Post date:** [2 June 2007 00:49 UTC](https://rubytalk.org/t/new-project-was-re-logging-off-windows-users-remotely-with-ruby/38033/2 "2007-06-02T00:49:27Z")

</div>

# active\_wmi  
# ar\_wmi  
# wmi\_rb  
# ruby-wmi  
# rWMI  
# wmi4r

me vote for ruby-wmi

> **···**
>
> From: Gordon Thiesfeld [[mailto:gthiesfeld@sbcglobal.net](mailto:gthiesfeld@sbcglobal.net)] :
