Need VBS help: Copying a Folder from a Network Share to the C: Drive.
Hello
My former colleague wrote the script but for some reason it doesn't work (nothing happens). Its supposed to have worked before, I am at a loss to explain why it doesn't now.
The object of the script is very basic. Copy a folder named "ebuns" from a network share and place it in the local directory "c:\Applications\ebuns". The EBUNS folder is about 450MB.
I ran it through a editor (VBSEDIT), and it came back with no errors so I am confused as to why it doesn't work. To my noob eye it looks OK but does anything look off to any of you?
Note: Anything with a xxx was removed by me for confidentiality reasons.
Option Explicit
Dim objFSO, objFolder, strDirectory1, strFileName, strSourcePath, strDestPath
strDirectory1 = "C:\Applications\eBuns"
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSourcePath ="\\xxx\afs_altiris\Scripts\xxx_eBUNS_v4.0_R1\Files\*.*"
strDestPath = "C:\Applications\eBuns"
If objFSO.FolderExists(strDirectory1) Then
objFSO.CopyFile (strSourcePath), (strDestPath)
Else
WScript.Quit(0)
End If
If any of you VBS gurus could help a colleague I'd sure appreciate it. (and yes Ill get some more practice after this)
Thanks.
4 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
genfoch01
10 years ago
if the destination path ends with a path separator (\), it is assumed that destination is an existing folder in which to copy matching files. Otherwise, destination is assumed to be the name of a file to create.
so I'd try changing strDestPath = "C:\Applications\eBuns" to strDestPath = "C:\Applications\eBuns\"
I would also clean up strDestPath and strDestPath1 which are different strings that appear to have the same value..
nice MS reference here:
http://msdn.microsoft.com/en-us/library/e1wf9e7w%28v=vs.84%29.aspx
so I'd try changing strDestPath = "C:\Applications\eBuns" to strDestPath = "C:\Applications\eBuns\"
I would also clean up strDestPath and strDestPath1 which are different strings that appear to have the same value..
nice MS reference here:
http://msdn.microsoft.com/en-us/library/e1wf9e7w%28v=vs.84%29.aspx
strDestPath
strDestPath
strDestPath = "C:\Applications\eBuns"
Have you tested it on machine where folder "C:\Applications\eBuns" was present? - rad33k 10 years ago
Rad33k Got it. If the C:\Applications\ebuns doesn't exsist the script wont run. I am checking to see why this is clause was added to the script but it at least answers why it didn't work. - mmarsh 10 years ago