WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: DAG_P6 on September 15, 2013, 01:47:36 AM

Title: Reasons for FileRename to Fail
Post by: DAG_P6 on September 15, 2013, 01:47:36 AM
I have a WB script that contains a large UDF that calls FileRename from two spots. In reviewing the code in preparation for writing this message, I noticed that one of the two calls is in an IF statement that creates one of two log entries, depending on whether or not FileRename succeeded. This I shall fix, but it begs a question.

If a file exists, is not marked read only, and was created by a program that runs in the same security context as this program, what would cause the rename to fail?
What am I missing?
Title: Re: Reasons for FileRename to Fail
Post by: td on September 16, 2013, 07:36:02 AM
Permission inheritance for one thing.
Title: Re: Reasons for FileRename to Fail
Post by: td on September 16, 2013, 09:57:04 AM
Also, because the creator/owner of an object is a member of a group does not necessarily mean that all members of that group have the same permissions as the owner.  Just a thought...
Title: Re: Reasons for FileRename to Fail
Post by: DAG_P6 on September 16, 2013, 04:49:00 PM
Thanks for all the ideas to consider. However, something that I neglected to mention is that the problem is intermittent, but the programs that are creating and renaming the files are the same, and they run every day. Each day, a file is downloaded, unpacked, and renamed. Most days, everything goes according to plan. Every now and again, though, the file rename fails, for no immediately apparent reason. A similar operation in a subsequent step usually works; 15 sets of files are processed each night.
Title: Re: Reasons for FileRename to Fail
Post by: Deana on September 17, 2013, 08:10:20 AM
In the code that captures the FileRename error, make sure you are getting the extended error information.

QuoteGetting Extended Error Information:

Most WIL errors are accompanied by 'extended error information'. Extended error information is written to the wwwbatch.ini file:

"C:\Documents and Settings\{username}\Application Data\WinBatch\Settings\wwwbatch.ini"


There is a section that contains additional diagnostic information that may give some clue as to what it is that failed. 

IntControl 73 returns this same information in the 'wberroradditionalinfo' variable.

Extended error information is most commonly in the form of a Windows system error.
Title: Re: Reasons for FileRename to Fail
Post by: td on September 17, 2013, 01:42:46 PM
Good point.  Likely it's an error 5, 32 or 183.
Title: Re: Reasons for FileRename to Fail
Post by: DAG_P6 on September 17, 2013, 06:31:20 PM
The production code doesn't fully implement the new error handlers that take full advantage of the goodies in the array. Thankfully, the next upgrade does.

It's amazing how clear many problems become when you can see the underlying system error. Sadly, I've seen all three at one time or another.