Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy folder from network to local drive 1

Status
Not open for further replies.

TooNew

Programmer
Aug 29, 2003
23
US
Running xp sp2 on both machines

I want a script to copy a folder from the network to a local drive.

This code works: (copy local to network)
Set FSO =CreateObject("scripting.FileSystemObject")
FSO.CopyFolder "c:\Backup" ,"\\Pta-srv\sjvwebsite", True
MsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"

This code generates an error: (copy network to local)
Set FSO =CreateObject("scripting.FileSystemObject")
FSO.CopyFolder "\\Pta-srv\sjvwebsite", "c:\Backup" ,True
MsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"

I think I looked at 90% of the posts and from what I see the code should work. I get "Invalaid Procedure Call or Argument"

I tried drive mapping and using IP address (as I found in the posts) still no luck except with IP address I got as far as "permission denied".

I'm sure I'm missing somethng very basic!

Thanks for some help.
 
Hi,

I Don't think your script is the problem.
I copied your script and it works fine with me.

You mentioned the "Permission Denied" --> can you do the copy manually ?
I would (re)check the permissions on the source and destination directory...

Hope you find it...

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
TooNew,

To do the thing you've in mind on the root of the share, proceed like this.
Code:
Set FSO =CreateObject("scripting.FileSystemObject")
FSO.CopyFolder "\\Pta-srv\sjvwebsite\*", "c:\Backup\" ,True
FSO.CopyFile "\\Pta-srv\sjvwebsite\*", "c:\Backup\", True
MsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"
regards - tsuji
 
K0b3 Yes, I can copy the folder manually. Thanks for taking the time to help.

tsuji - Thank you very much for the help. This works fine. Obviously, I don't understand the basics of communicating with a network. It's not something I normally have to do. Thanks again.
 
Tsuji,

I know now this is the best way to do it, but can you explain me why the code TooNew used previously worked.
I tested it and it copied eveything (files, folders, subfolders,...)

any idea?

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
TooNew & K0b3,

The reason it fails is that as such, it means to copy the share itself---which is just a way to interprete it---but not the resources exposed from the share. To plug this unwelcoming interpretation, you can use the wildcard "*" to indicating the resources: folders for copyfolder, files for copyfile.

Whereas deeper down from the root, there won't be such problem, such as:
[tt]FSO.CopyFolder "\\Pta-srv\sjvwebsite\abc", "c:\Backup\" ,True[/tt]
would copy the folder abc itself things it contains.

Thanks for your attention.

- tsuji
 
tsuji
Thanks for additional information. I now realize that I did not identify the specific resources I wanted to copy. I was just doing a test and thought "I would just copy it all" to see if the code worked ok. I'm sure this additional insight will help when I eventually move the code to an enviromnent where the server has multiple shares etc.
Thank again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top