# Managing Windows from Linux via Ruby

**URL:** <https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959>\
**Category:** Ruby\
**Created:** [March 4, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959 "2008-03-04T20:15:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 4, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/1 "2008-03-04T20:15:06Z")

</div>

Does anyone know of a reliable way to manage resources on Windows  
machines  
from a Linux platform using Ruby? I’m currently using win32api and  
win32ole  
to create directories and set permissions on multiple remote Windows  
machines but would like to migrate my application to a Linux platform.  
I’m  
also interacting with AD but that works fine with LDAP.

Anyone have any suggestions on how I could go about this, or is it not  
worth  
my while?

Thanks,  
Glen

–  
“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)

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 4, 2008, 10:23pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/2 "2008-03-04T22:23:15Z")

</div>

On Tue, Mar 4, 2008 at 11:14 AM, Glen H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Does anyone know of a reliable way to manage resources on Windows machines  
> from a Linux platform using Ruby? I’m currently using win32api and win32ole  
> to create directories and set permissions on multiple remote Windows  
> machines but would like to migrate my application to a Linux platform. I’m  
> also interacting with AD but that works fine with LDAP.
> 
> Anyone have any suggestions on how I could go about this, or is it not worth  
> my while?

One reasonably cheap way is to use win32-service to run a drb server  
that calls your other windows libraries across the network from your  
linux box. I’ve used this approach quite successfully, albeit for very  
trivial tasks. I used rubyscript2exe and srvany.exe to make the  
service, because i was unaware of win32-service at the time; if I had  
to do it again I’d probably use the latter.

martin

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 4, 2008, 10:34pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/3 "2008-03-04T22:34:39Z")

</div>

On Tue, Mar 4, 2008 at 2:22 PM, Martin DeMello [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > 
> 
> martin

Thanks for the idea Martin. It doesn’t sound too horrible. I’ll look  
into  
it.

–  
“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)

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 5, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/4 "2008-03-05T21:40:42Z")

</div>

If you can access the windows boxes through SSH , you can trigger the  
execution of any code you may run on the remote machine.  
Drb is a more elegant solution.

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 5, 2008, 10:53am UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/5 "2008-03-05T10:53:28Z")

</div>

> I’ve used this approach quite successfully, albeit for very  
> trivial tasks.

Trivial tasks sound great, it makes understanding them easier 🙂

Do you have a few example scripts for that? Just a few things what  
is possible like that, snippets and the like.  
(If you dont, dont worry, I dont intend to steal anyone’s time).

I am using Linux mostly, but it would be nice if all the scripts on my  
Linux box could work on my Windows machine just as well - but with me  
staying here, and not even connecting via ssh or similar.

---

<div class="post-metadata">

**Author:** ![Glen\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/34f0e0/32.png) [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Post date:** [March 5, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/managing-windows-from-linux-via-ruby/130959/6 "2008-03-05T22:27:22Z")

</div>

On Wed, Mar 5, 2008 at 1:53 AM, Marc H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > I’ve used this approach quite successfully, albeit for very  
> > trivial tasks.
> 
> Trivial tasks sound great, it makes understanding them easier 🙂
> 
> Do you have a few example scripts for that? Just a few things what  
> is possible like that, snippets and the like.  
> (If you dont, dont worry, I dont intend to steal anyone’s time).

Sorry, no ☹ It was a while ago and I don’t have a windows box any  
more. The basic setup was very simple, though - I wrote a bunch of  
code to do stuff, based on the excellent ruby-win32 library, then I  
created an object that exposed all the methods thro drb, ran the  
script through rubyscript.exe to create an executable, and then ran  
anysrv.exe and instsrv.exe from the windows resource kit to install it  
as a service. One problem is that sometimes stopping the service left  
a stray ruby.exe process lying around, which is why I said I’d do it  
using win32-service rather than anyserv if I had to do it again.

martin
