FileRename Failure

Started by geauga, February 28, 2019, 02:50:55 PM

Previous topic - Next topic

geauga

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?

td

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. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

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.
The mind is everything; What you think, you become.

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade