Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


CopyFolder Method

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,30411
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> CopyFolder Method
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 CopyFolder Method - 1/30/2006 7:28:42 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
What am I doing wrong?

Need to copy this folder from a network share onto the local computer. Script will be run from various clients.

Keep on getting an error message on Line 7, Char 1 Object Required: " Code 800A01A8

Dim fso
sFolder = "\\source"
dFolder = "C:\destination"
Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\crystal")
fso.CopyFolder sFolder, dFolder, overwritefiles
Wscript.Echo("All Done. Please restart your computer")



 
 
Post #: 1
 
 RE: CopyFolder Method - 1/30/2006 7:33:05 AM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi jlcarey,

I didn't test, but

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFolder = objFSO.CreateFolder("C:\crystal")
  fso.CopyFolder sFolder, dFolder, overwritefiles

looks fishy to me.

ehvbs

(in reply to jlcarey1)
 
 
Post #: 2
 
 RE: CopyFolder Method - 1/30/2006 7:36:41 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
Could you be more specific?

(in reply to jlcarey1)
 
 
Post #: 3
 
 RE: CopyFolder Method - 1/30/2006 7:41:17 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Well for one thing, you never instantiate fso. Then you try to use it to copy a folder even though it is not any sort of object let alone a FileSystemObject.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jlcarey1)
 
 
Post #: 4
 
 RE: CopyFolder Method - 1/30/2006 7:49:38 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
See red additions and comments below.

Dim fso
sFolder = "\\source"
dFolder = "C:\destination"
Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\crystal")
objfso.CopyFolder sFolder, dFolder, overwritefiles
Wscript.Echo("All Done. Please restart your computer")


Red - You were missing.
Blue - Why are you creating this if you are not using it?  Without checking to see if exists you may get an error when it already exists.

Cybex

_____________________________

Common sense is not so common.

(in reply to jlcarey1)
 
 
Post #: 5
 
 RE: CopyFolder Method - 1/30/2006 7:51:04 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
ebgreen beat me to the punch...

Cybex

_____________________________

Common sense is not so common.

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: CopyFolder Method - 1/30/2006 8:24:12 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
This is exactly what I have and it does not work:

Dim fso
sFolder = "\\source" 'This source is from a Network File Server
dFolder = "C:\destination"
Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objfso.CopyFolder sFolder, dFolder, overwritefiles
Wscript.Echo("All Done. Please restart your computer")

Error:

Line: 6
Char: 1
Error: Invalid procedure call or argument
Code: 800A0005

(in reply to jlcarey1)
 
 
Post #: 7
 
 RE: CopyFolder Method - 1/30/2006 8:28:18 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
That may be exactly what you have NOW, but that wasn't what you had.  Don't make it sound like what we corrected was wrong.

Try echoing your source and destination variables and make sure they are formatted and being passed correctly.

Cybex

< Message edited by Cybex -- 1/30/2006 8:30:13 AM >


_____________________________

Common sense is not so common.

(in reply to jlcarey1)
 
 
Post #: 8
 
 RE: CopyFolder Method - 1/30/2006 8:28:21 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Well, my first thing to look at is sFolder = "\\source". The \\ indicates that this is a UNC path and that source is the name of the server. So are you trying to copy an entire server to a folder?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jlcarey1)
 
 
Post #: 9
 
 RE: CopyFolder Method - 1/30/2006 8:31:07 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
No he is just obscuring the actual path and server names for the post.

Cybex

_____________________________

Common sense is not so common.

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: CopyFolder Method - 1/30/2006 8:32:17 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
No, I am just trying to copy one shared folder from a network server to a client computer.

(in reply to jlcarey1)
 
 
Post #: 11
 
 RE: CopyFolder Method - 1/30/2006 8:33:00 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Well, then yes he will need to echo the value of those vars to verify their validity.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Cybex)
 
 
Post #: 12
 
 RE: CopyFolder Method - 1/30/2006 8:38:18 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
Do I need to bind to that folder first?

The funny thing is that I wrote a similar script a few weeks ago which copied a folder from a network share and it worked. Only thing is, I accidentally deleted it!!! 

It's failing at objFSO.Copyfolder

(in reply to jlcarey1)
 
 
Post #: 13
 
 RE: CopyFolder Method - 1/30/2006 8:42:47 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
You do not need to bind to the folder. The copyfolder method takes a string for a path. Please run the following code posting back here with what is output. I realize that you may need to change some of the information for security, but change as little as possible:

      

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jlcarey1)
 
 
Post #: 14
 
 RE: CopyFolder Method - 1/30/2006 9:19:16 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
Source, Destination, Overwrite are all correct.
Same error on objfso.copyfolder line

Is there something different with connecting to a network file share? I checked the permissions on that share and they are correct.

(in reply to jlcarey1)
 
 
Post #: 15
 
 RE: CopyFolder Method - 1/30/2006 9:22:11 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
I know that you think they are correct, but could you please post the output? you can change every letter to x for all I care. Just don't change any of the non-letter characters to something else.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jlcarey1)
 
 
Post #: 16
 
 RE: CopyFolder Method - 1/30/2006 9:33:15 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
Source: \\fileserver\\crystal_9_dll$\\bin

Destination: C:\Crystal

Overwrite: True

Line: 9
Char: 4
Error: Invalid procedure call or argument
Code: 800A0005
Source: Microsoft VBScript runtime error

(in reply to jlcarey1)
 
 
Post #: 17
 
 RE: CopyFolder Method - 1/30/2006 9:34:31 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
This:
Source: \\fileserver\\crystal_9_dll$\\bin

should be:

Source: \\fileserver\crystal_9_dll$\bin

That is the problem. How do you generate that path?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jlcarey1)
 
 
Post #: 18
 
 RE: CopyFolder Method - 1/30/2006 9:38:42 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
The location of the actual folder I want to copy is \\fileserver\crystal_9_dll$\bin

The share name is \\fileserver]crystal_9_dll$

Maybe I need to remove the double \\ in between everything?

and just put quotes in front and end of that location?

(in reply to ebgreen)
 
 
Post #: 19
 
 RE: CopyFolder Method - 1/30/2006 9:40:49 AM   
  jlcarey1

 

Posts: 14
Score: 0
Joined: 8/30/2005
From: Long Island, NY
Status: offline
That was it.

stupid, stupid error.

Thanks for your help. really appreciate it. Sometimes, you just get lost when looking at code and your miss the simple things

(in reply to jlcarey1)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> CopyFolder Method Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts