/build/static/layout/Breadcrumb_cap_w.png

Need VBS help: Copying a Folder from a Network Share to the C: Drive.

Hello

Our Scripting person left the company last month and has been replaced by a scripting noob (me). I am total beginner at this. A took a course a year ago, understood little, and that's about all my vbs experience until now...

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
  • who are you running this as? do they have rights to the share and rights to the local system directory to copy the files. - SMal.tmcc 9 years ago
  • ...that is to say, which account is running the script? If it's the local System account. for example, it will have no network access. - anonymous_9363 9 years ago
  • Besides possible access issue, you script will copy files only if folder "C:\Applications\eBuns" will exist. If not it quits and does nothing...
    Have you tested it on machine where folder "C:\Applications\eBuns" was present? - rad33k 9 years ago
  • Thanks Guys...
    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 9 years ago

Answers (1)

Posted by: genfoch01 9 years ago
Orange Senior Belt
0
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
strDestPath
strDestPath
strDestPath = "C:\Applications\eBuns"
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ