WSH Object error on specific filename

Discussion in 'Javascript' started by Paul E. Schoen, Apr 5, 2010.

  1. I have a simple JavaScript utility that saves specific files to a directory.
    It was originally developed on my XP machine and I recently made some
    changes for the Vista machine I am now using. I also added several files to
    the lists, and I saw an "Object Error", which I traced to a specific file. I
    saw that it was ReadOnly, so I changed that without success. But if I
    renamed it, the script ran fine, even if the renamed file was made ReadOnly.

    Here is a portion of the script that throws the error:

    Path = "C:\\Users\\Paul\\Documents\\Delphi\\PStechLib\\"
    DestFolder = "LibCode\\";

    WScript.Echo("Saving PStechLib project files to Folder " + Path +
    DestFolder);

    SourceFile[0] = "Debug.*";
    SourceFile[1] = "xygraph.*";
    // ....
    SourceFile[13] = "SerialNG.dcu";
    SourceFile[14] = "SerialNGx.pas"; // Error if I use SerialNG.pas or
    SerialNG*.*

    MAXFILES = 15; //Set to one higher than last index
    FileList = "";
    FilesSaved = 0;

    try {
    for (i=0; i < MAXFILES; i++) {
    fso.CopyFile ( Path+SourceFile, Path+DestFolder);
    FileList += SourceFile + " ";
    FilesSaved++; }
    }

    catch(e) {
    WScript.Echo("Error " + e); }

    finally {
    WScript.Echo( FileList );
    WScript.Echo( FilesSaved + " Files Saved"); }

    I'd rather not use the workaround of renaming a file, but rather understand
    and fix this odd behavior. If I put the offending file earlier in the list,
    it throws the error and does not process the rest. I no longer have a
    working XP machine to see if it's an OS quirk. Ideas?

    Thanks,

    Paul
     
    Paul E. Schoen, Apr 5, 2010
    #1
    1. Advertising

  2. Paul E. Schoen

    err_ Guest

    On Apr 5, 2:48 pm, "Paul E. Schoen" <> wrote:
    > I have a simple JavaScript utility that saves specific files to a directory.
    > It was originally developed on my XP machine and I recently made some
    > changes for the Vista machine I am now using. I also added several files to
    > the lists, and I saw an "Object Error", which I traced to a specific file.. I
    > saw that it was ReadOnly, so I changed that without success. But if I
    > renamed it, the script ran fine, even if the renamed file was made ReadOnly.
    >
    > Here is a portion of the script that throws the error:
    >
    >   Path = "C:\\Users\\Paul\\Documents\\Delphi\\PStechLib\\"
    >   DestFolder = "LibCode\\";
    >
    >   WScript.Echo("Saving PStechLib project files to Folder " + Path +
    > DestFolder);
    >
    >   SourceFile[0] = "Debug.*";
    >   SourceFile[1] = "xygraph.*";
    > //  ....
    >   SourceFile[13] = "SerialNG.dcu";
    >   SourceFile[14] = "SerialNGx.pas";    // Error if I use SerialNG..pas or
    > SerialNG*.*
    >
    >   MAXFILES = 15; //Set to one higher than last index
    >   FileList = "";
    >   FilesSaved = 0;
    >
    >   try {
    >     for (i=0; i < MAXFILES; i++) {
    >     fso.CopyFile ( Path+SourceFile, Path+DestFolder);
    >     FileList += SourceFile + "  ";
    >     FilesSaved++; }
    >   }
    >
    >   catch(e) {
    >   WScript.Echo("Error " + e); }
    >
    >   finally {
    >   WScript.Echo( FileList );
    >   WScript.Echo( FilesSaved + " Files Saved"); }
    >
    > I'd rather not use the workaround of renaming a file, but rather understand
    > and fix this odd behavior. If I put the offending file earlier in the list,
    > it throws the error and does not process the rest. I no longer have a
    > working XP machine to see if it's an OS quirk. Ideas?
    >
    > Thanks,
    >
    > Paul


    It looks like the code you pasted is missing a semicolon at the end of
    the first line, maybe that has something to do with it?
     
    err_, Apr 5, 2010
    #2
    1. Advertising

  3. "err_" <> wrote in message
    news:...
    On Apr 5, 2:48 pm, "Paul E. Schoen" <> wrote:
    > I have a simple JavaScript utility that saves specific files to a
    > directory.

    [snip]
    >
    > Path = "C:\\Users\\Paul\\Documents\\Delphi\\PStechLib\\"
    > DestFolder = "LibCode\\";

    [snip]

    It looks like the code you pasted is missing a semicolon at the end of
    the first line, maybe that has something to do with it?

    Thanks for pointing that out, but it did not fix the problem. I think
    semicolons at the end of lines are optional for WSH scripts.

    Paul
     
    Paul E. Schoen, Apr 5, 2010
    #3
  4. "Paul E. Schoen" <> wrote in message
    news:DLqun.39665$...
    > "err_" <> wrote in message
    > news:...
    > On Apr 5, 2:48 pm, "Paul E. Schoen" <> wrote:
    >> I have a simple JavaScript utility that saves specific files to a
    >> directory.

    > [snip]
    >>
    >> Path = "C:\\Users\\Paul\\Documents\\Delphi\\PStechLib\\"
    >> DestFolder = "LibCode\\";

    > [snip]
    >
    > It looks like the code you pasted is missing a semicolon at the end of
    > the first line, maybe that has something to do with it?
    >
    > Thanks for pointing that out, but it did not fix the problem. I think
    > semicolons at the end of lines are optional for WSH scripts.


    Now it seems that the name SerialNGx.pas has also been "poisoned" so I had
    to rename it as SerialNG0.pas. Maybe Vista has a memory of files that caused
    problems and checks them first?

    Paul
     
    Paul E. Schoen, Apr 5, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,035
    Travis Murray
    Aug 24, 2004
  2. Replies:
    1
    Views:
    1,501
    Roland de Ruiter
    Jun 15, 2006
  3. Ed
    Replies:
    10
    Views:
    46,002
    alok000707
    Jul 13, 2010
  4. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    761
    Jonathan N. Little
    May 30, 2008
  5. Yitzhak
    Replies:
    2
    Views:
    332
    Jonathan B.
    Jan 21, 2004
Loading...

Share This Page