WSH Object error on specific filename

P

Paul E. Schoen

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
 
E

err_

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?
 
P

Paul E. Schoen

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
 
P

Paul E. Schoen

Paul E. Schoen said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top