# Connecting to a Windows share from a Windows computer

**URL:** <https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951>\
**Category:** Ruby\
**Created:** [July 13, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951 "2008-07-13T22:15:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 13, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/1 "2008-07-13T22:15:07Z")

</div>

We have two separate servers running Windows Server 2003, and what we  
need to do is simply copy files from a share on one of the computers to  
the other, the computers share a domain. I assume there is some simple  
library that I can’t find and was hoping someone could share that with  
me. If necessary, I will be able to provide more information or let you  
know if it’s working tonight around 1 AM CDT.

Thanks for reading, and I’m sorry if I choose the wrong topic in which  
to post this.

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 1:00am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/2 "2008-07-14T01:00:35Z")

</div>

-------- Original-Nachricht --------

> Datum: Mon, 14 Jul 2008 05:10:41 +0900  
> Von: Kory W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: Connecting to a Windows share from a Windows computer

> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).  
> Dear Kory,

just guessing here:

maybe win32-service from

[http://win32utils.rubyforge.org/](http://win32utils.rubyforge.org/) can do what you want.

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 3:09am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/3 "2008-07-14T03:09:38Z")

</div>

Axel E. wrote:

> -------- Original-Nachricht --------
> 
> > Datum: Mon, 14 Jul 2008 05:10:41 +0900  
> > Von: Kory W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > An: removed\_email\_address@domain.invalid  
> > Betreff: Connecting to a Windows share from a Windows computer
> 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).  
> > Dear Kory,
> 
> just guessing here:
> 
> maybe win32-service from
> 
> [http://win32utils.rubyforge.org/](http://win32utils.rubyforge.org/) can do what you want.
> 
> Best regards,
> 
> Axel

Thanks Axel, I did check that out, but couldn’t find anything that could  
do what I wanted. Per your suggestion, I will look into it more.  
Thanks for the reply!

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 7:35am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/4 "2008-07-14T07:35:45Z")

</div>

BjÃ¶rn Andersson wrote:

> Hi!
> 
> Have you tried to just copy it using the normal UNC path?  
> \server1\mountpoint\otherfile -\> \server2\mountpoint\yourfile.txt  
> If you need to authenticate to the servers use the “net use” command  
> and mount the network shares as local drives and unmount them when the  
> copy is done.
> 
> Not really a ruby specific answer but maybe something. 🙂
> 
> /Bjï¿½rn

Thanks very much for the reply, I’ll give the first part a go, but have  
a question: can it work with directories (\server1\mountpoint\* -\>  
\server2\infodate\ as well as files, and what is the method call for  
which I’d be looking?

I’ll definitely try/look into this deeper, though. Thanks a lot BjÃ¶rn!

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 7:20am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/5 "2008-07-14T07:20:00Z")

</div>

Hi!

Have you tried to just copy it using the normal UNC path?  
\server1\mountpoint\otherfile -\> \server2\mountpoint\yourfile.txt  
If you need to authenticate to the servers use the “net use” command  
and mount the network shares as local drives and unmount them when the  
copy is done.

Not really a ruby specific answer but maybe something. 🙂

/Björn

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 10:34am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/6 "2008-07-14T10:34:59Z")

</div>

I had not tested wether using the UNC path would work before but with  
File.copy it didn’t.  
So I think the easiest would be to mount the shares using the windows  
command “net use” and then copy to the drives.

For copying an entire directory look at the File class and also Dir to  
iterate over and copy the files in the directory.

/BjÃ¶rn

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 11:42am UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/7 "2008-07-14T11:42:22Z")

</div>

Thank you greatly BjÃ¶rn, your advice is priceless, even if it’s not  
exactly ruby :), thanks for getting me back on track and making me do a  
little research on my own :D.

Also, thank you Axel for your response, as it would have come in a great  
deal of use just a few days ago.

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 2:30pm UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/8 "2008-07-14T14:30:38Z")

</div>

Hi Kory,

Kory W. wrote:

> We have two separate servers running Windows Server  
> 2003, and what we need to do is simply copy files from  
> a share on one of the computers to the other, the computers  
> share a domain.

Assuming you’re talking about doing this in the context of Rails, or at  
least Ruby, you might take a look at Ruby’s open-uri library.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![panth0r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@panth0r](https://www.ruby-forum.com/u/panth0r)\
**Post date:** [July 14, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/connecting-to-a-windows-share-from-a-windows-computer/142951/9 "2008-07-14T18:29:04Z")

</div>

Thanks everyone for all your help, I managed to resolve it using mostly  
BjÃ¶rn’s suggestions using essentially a few MSDOS commands within a ruby  
method. This is a nice community you guys have going here, hope I can  
be the helper someday, and be sure to stop by once in a while. If  
anyone is interested, I’ll post what I came up with tomorrow morning,  
CDT. Thanks again everyone!
