WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: geauga on February 28, 2019, 02:50:55 PM

Title: FileRename Failure
Post by: geauga on February 28, 2019, 02:50:55 PM
I have code that checks for the existence of a file.  If it exists it renames the file.  Later in my code I go to do a second FileRename that always fails with a System Error 183.  This error 183 is valid because the first FileRename fails.  The first FileRename give a system error 2 which say that the file does not exist.  It does exist.  From a security standpoint the first file has wide open security.  Any suggestions?
Title: Re: FileRename Failure
Post by: td on March 01, 2019, 07:01:55 AM
It is very difficult to win an argument with a system error code.  You need to reconsider your assumptions and your script's logic.  Consider stepping through your script with the WinBatch Studio debugger while not making any assumptions about the contents of any variables or string literals.  The latter bit being the hard part. 
Title: Re: FileRename Failure
Post by: kdmoyers on March 04, 2019, 04:06:48 AM
I can add that if things are happening quickly, and the files are on a windows server, their current state can become muddled.  I can't tell you how many times I've had file update/rename/delete issues evaporate when I run a program one-line-at-time in the debugger.  Sometimes, a one second delay in the right spot makes the problems go away.

But first, you have to isolate the problem.  For this, the Studio debugger is a wonderful thing.  Huge time saver.
Title: Re: FileRename Failure
Post by: td on March 04, 2019, 07:47:03 AM
MSFT's SMB protocol has gone through several iterations over the last half-decade or so and those iterations have not always been implemented bug-free.  We have seen cases, where file manipulates like file deletes and moves are only respected on every other attempt when accessing files on Windows Server shares.