Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > WSH Object error on specific filename

Reply
Thread Tools

WSH Object error on specific filename

 
 
Paul E. Schoen
Guest
Posts: n/a
 
      04-05-2010
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[i], Path+DestFolder);
FileList += SourceFile[i] + " ";
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

 
Reply With Quote
 
 
 
 
err_
Guest
Posts: n/a
 
      04-05-2010
On Apr 5, 2:48*pm, "Paul E. Schoen" <(E-Mail Removed)> 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[i], Path+DestFolder);
> * * FileList += SourceFile[i] + " *";
> * * 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?
 
Reply With Quote
 
 
 
 
Paul E. Schoen
Guest
Posts: n/a
 
      04-05-2010
"err_" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Apr 5, 2:48 pm, "Paul E. Schoen" <(E-Mail Removed)> 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

 
Reply With Quote
 
Paul E. Schoen
Guest
Posts: n/a
 
      04-05-2010

"Paul E. Schoen" <(E-Mail Removed)> wrote in message
newsLqun.39665$(E-Mail Removed)...
> "err_" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> On Apr 5, 2:48 pm, "Paul E. Schoen" <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The filename set in the response.setHeader("Content-Disposition", "attachment; filename=test.csv") is being ignored! Ed Java 10 07-13-2010 12:43 PM
Stitch rar files ( filename.part01 and filename.part02) Please help ixgor Software 1 10-15-2006 02:33 AM
how to get 8.3 format filename from long filename jacobyv@sis.unibe.ch Java 1 06-15-2006 10:39 AM
Extract filename from a filename typed by user =?Utf-8?B?Sm9l?= ASP .Net 1 08-23-2004 11:29 PM
"Permission denied" error while calling WSH's LogEvent method Yitzhak ASP General 2 01-21-2004 11:15 PM



Advertisments