# Connect to Windows Share using Ruby

**URL:** <https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140>\
**Category:** Ruby\
**Created:** [November 12, 2008, 4:49pm UTC](https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140 "2008-11-12T16:49:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [November 12, 2008, 4:49pm UTC](https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140/1 "2008-11-12T16:49:01Z")

</div>

Hello,

I’m looking to connect to a Windows share using Ruby. Is there a  
library, or gem that would help me do this? Just a nudge in the right  
direction would be great. Thank you!

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [November 13, 2008, 12:23am UTC](https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140/2 "2008-11-13T00:23:06Z")

</div>

Nick H. wrote:

> Hello,
> 
> I’m looking to connect to a Windows share using Ruby. Is there a  
> library, or gem that would help me do this? Just a nudge in the right  
> direction would be great. Thank you!

Nick,  
[http://rubysmb.sourceforge.net/](http://rubysmb.sourceforge.net/) may do the trick for you, if you mean  
connecting to Windows from Linux, and have Samba already configured.

HTH,  
Howard

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [November 13, 2008, 5:40am UTC](https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140/3 "2008-11-13T05:40:26Z")

</div>

I couldn’t find the original post so I’ll reply to this one…

require ‘fileutils’ # optional, but so much stuff comes in handy…  
Dir.chdir("//servername/sharename/")

That usually does the trick for me… Or do you need something else?

–Aldric

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [November 13, 2008, 3:46pm UTC](https://www.ruby-forum.com/t/connect-to-windows-share-using-ruby/153140/4 "2008-11-13T15:46:09Z")

</div>

Aldric G. wrote:

> I couldn’t find the original post so I’ll reply to this one…
> 
> require ‘fileutils’ # optional, but so much stuff comes in handy…  
> Dir.chdir("//servername/sharename/")
> 
> That usually does the trick for me… Or do you need something else?
> 
> –Aldric

Yeah, all of the above works for me. I just didn’t know if there was a  
more ‘built in’ way to connect rather than relying on the host OS to  
handle the communication. Having Ruby take care of it would make the  
code much more portable.
