trying to write a script that copies files from 1 drive to another

Posted on 2004-11-05
Last Modified: 2010-04-17
Hello and thanks in advance,

I am trying to write a .vbs script that copies files from one drive to another and matches the folder path exactly. I have bought a scripting book. I am going through the examples and for some reason windows keeps blowing an error @ line 3 of the following code. I understand that just because it says line 3 does not mean the error is in line 3.

Here is the code, can somebody tell me why it keep blowing errors?

folderP = CheckFolders
Set W = WScript.CreateObject
w.Popup folderP
Function CheckFolders(folderPath)

Dim fs, f, n, s
s = ""
n = 0
Set fs = CreateObject
Set f = fs.GetFolder(folderPath)
If f.IsRootFolder then
s = "this is the root level"
 Do Until f.IsRootFolder
  Set f = f.ParentFolder
   n = n + 1
 End If
 'work with folder
s = "Folder is nested " & n & " levels deep"

CheckFolders = s
End Function

Question by:Drew_Mora
    LVL 9

    Accepted Solution


    Try taking the line break out between lines 2 and 3

    Author Comment

    by:Drew_Mora da man! I feel so stupid!!!
    LVL 9

    Expert Comment


        Thank you, glad I could help, Thanks for the A   : )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Title # Comments Views Activity
    post4 challenge 28 70
    fix34  challenge 9 70
    wordsWithout 49 64
    pairs challenge 5 29
    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    A short article about a problem I had getting the GPS LocationListener working.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now