Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

shortmort37

I performed the icacls command as you suggested, but the result is the same:
< 2025-10-14 10:53:53.754 Script: Synchronizing...

. 2025-10-14 10:53:53.754 Synchronizing local directory 'I:\vps116136\faulkner\59forum\vendor\' with remote directory '/home/faulkner/public_html/59forum/vendor/', params = 0x3 (Delete, NoConfirmation)
< 2025-10-14 10:53:53.770 Script: Error deleting file 'I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Service'.
< 2025-10-14 10:53:53.770 System Error.  Code: 5.

< 2025-10-14 10:53:53.770 Access is denied
. 2025-10-14 10:53:53.770 Script: Failed
. 2025-10-14 10:53:53.770 Script: Exit code: 1

And then via CMD:
I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Service>dir

 Volume in drive I is Data Drive
 Volume Serial Number is BCC8-BC56

 Directory of I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Service

07/24/2024  10:21 AM    <DIR>          .
07/24/2024  10:21 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  1,025,259,339,776 bytes free

I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Service>cd ..

I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common>rmdir Service
Access is denied.

As before, I was able to delete the directory with Windows Explorer.
"dan" is a member of Administrators, but generally I am prompted by Windows UAC to agree to an action that requires Administrative privileges; but not with Windows Explorer. In any event, CMD was launched as "dan" (but not as Administrator). Odd, too, that this seems to affect only subdirs, but not the files within them...
martin

I seems that the whole directory tree has some broken permissions (and new folders inherit that). Windows File Explorer is able to silently bypass permissions issues, when it is used by a user that has Admin privileges (I assume that's your case).
You can try to fix the permissions by:
icacls I:\vps116136\faulkner /reset /T
shortmort37

NEW INFORMATION!
I did as you asked, and ran the icacls command on ..\Http:
Http

D:NO_ACCESS_CONTROL

And got the same result, after its removal and recreation with CMD:
Http

D:NO_ACCESS_CONTROL

BUT! after I first ran icacls, I attempted to remove the empty Http subfolder with CMD - and got "Access Denied"! Yet, I was able to delete the subfolder with Windows Explorer!

I was able to rmdir with CMD, the Http subdir I had mkdir with CMD. While I have destroyed this test case, I am sure one of the other subfolders in the lusitanian folder will present with the same "Access Denied" error from WinSCP, as well as CMD. I am rerunning the script now.

What accounts for the fact that I can delete these folders - originally created with a WinSCP script - with Windows Explorer, but not CMD?
martin

Can you dump permissions of the folder that cannot be deleted using icacls I:\vps116136\faulkner\...? And then again after you recreate it (when it can be deleted)?
shortmort37

Just to note - I saved off the new phpBB directory tree, moved the old back in place, and reran the script:
< 2025-10-13 12:04:02.106 Script: Error deleting file 'I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http'.

< 2025-10-13 12:04:02.106 System Error.  Code: 5.
< 2025-10-13 12:04:02.106 Access is denied

As I said at the beginning of this thread, this is not the first time this error has occurred - usually, it is because a single directory is purged of files, but the directory itself is not removed. I know that it will happen again. But I will soon be deleting this directory which consistently produces an error, unless there is an interest in pursuing what might be responsible for it.

Dan
shortmort37

Should I conclude that there are no other diagnostics to pursue? If so, I will delete I:vps115136\59forum. Please advise.
shortmort37

Here's an update.

Having gone over a week now without a complete backup, I decided to move I:\vps116136\faulkner\59forum, along with all of its subfolders and files, up one level to I:vps115136\59forum. I then reran the script, re-backing up my entire site. It did so, and ran to completion without error. N.B.: Server-side, the ../lusitanian subfolder was gone as a result of the phpBB upgrade from 3.3.5 to 3.3.15.

As a further test, I then copied the 3.3.5 distribution lusitanian folder up into the vendor subfolder on the server. I then reran the script, and it updated my local backup to include the lusitanian folder.

I then deleted lusitanian server side, and reran the script. WinSCP removed the lusitanian subfolder and all of its files and subfolders successfully to completion.

I will keep the "saved-off" backup, and move it back into position (after moving off the complete, successful backup), if there is any interest in continuing to pursue this issue affecting WinSCP. But I am at a loss as to what is causing it, and I am concerned that it will happen again. Please advise.
shortmort37

Using the console command to synchronize, WinSCP emptied Uri of its files before complaining that it could not delete the folder itself, just as with Client and Exception. Now all three subfolders of Http were empty of files. As with Client and Exception, I used Windows Explorer to delete and recreate Uri. Repeating the console command, WinSCP now deleted all three subfolders before complaining that it could not delete the parent folder Http.

I will add: WinSCP initially created a copy of the V3.3.5 distribution of phpBB on my server to my local I: drive, including I:\vps116136\faulkner\59forum\vendor\lusitanian with all of its subfolders and files. At some point in development, phpBB removed lusitanian from the distribution, and I encountered these errors when upgrading to V3.3.15. But the directories that WinSCP is now attempting to delete, were initially created by WinSCP.
martin

The order in which folders are being synchronized is not necessarily deterministic. So please delete and recreate Exception too (and possibly later also Uri) and see what happens.
shortmort37

The plot thickens...
...\Http contains three subfolders - \Client, \Exception, and \Uri. At the outset of the latest experiment, Client was empty, the other two contained files.
When I ran synchronize in the console, it failed to remove Client. In Windows, I deleted it and recreated it; then, ran synchronize again:
Synchronizing...

Error deleting file 'I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http\Exception'.
System Error.  Code: 5.
Access is denied

Now it fails on Exception, which by the way, has been emptied of its contents by WinSCP. Note that Client - which I first deleted, then recreated - remains. I'll also note that Client has today's date (of course), but that Exception and Uri are dated July 24, 2024. Presumably, the original Client folder had the same 2024 date.
shortmort37

I have run C:\...\WinSCP.com, open... , set the local and remote working directories, followed by the synch. Again, I get this error:

Error deleting file 'I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http\Client'.

System Error.  Code: 5.
Access is denied

I then lcd down to ...\Http, but: What command can I give in the WinSCP console, to locally rmdir? "help" doesn't indicate that there is one.

At any rate, I will remove the subdir and recreate it with Windows Explorer, and try again.
shortmort37

Just to make sure I understand it correctly:
WinSCP fails to delete a particular local empty folder. Even after repeatedly running the same synchronization – still fails on the same folder.

This is correct.
You then delete the folder manually (in Windows Explorer), recreate the same folder – and then WinSCP is able to delete it. Is my understanding correct?

I haven't actually tried this experiment. What I did was create an entirely different path, per your suggestion, and confirm that with the folder removed from the server, WinSCP would delete on the desktop with sync. I have confirmed that if WinSCP fails to delete an empty folder on the desktop, I can remove it with Windows Explorer, subsequent to the script running, or manually running the GUI and leaving it open after the failure.
Also when the script is not able to delete the folder, is WinSCP GUI able to delete it? Both manually when selecting it in file panel and automatically by running the synchronization in GUI.

I will try this. Should it fail, I will delete and recreate with Windows Explorer, and repeat the experiment in the WinSCP GUI.
I'll report back with my findings.
martin

Again, thanks for all the thorough tests.

Just to make sure I understand it correctly:
WinSCP fails to delete a particular local empty folder. Even after repeatedly running the same synchronization – still fails on the same folder. You then delete the folder manually (in Windows Explorer), recreate the same folder – and then WinSCP is able to delete it. Is my understanding correct?

Also when the script is not able to delete the folder, is WinSCP GUI able to delete it? Both manually when selecting it in file panel and automatically by running the synchronization in GUI.
shortmort37

...and just for kicks - thinking that perhaps, the length of the string had something to do with it, I replicated locally in ..\folder the subdir that the script would not delete, as well as remotely in ../folder (excepting the target for deletion, the local "\Client" subdir):

...

Synchronizing...
Local 'c:\Users\dan\Documents\folder\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http' <= Remote '/home/faulkner/folder/59forum/vendor/lusitanian/oauth/src/OAuth/Common/Http'
'c:\Users\dan\Documents\folder\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http\Client' deleted
shortmort37

Well, that's not it:

...

winscp> pwd
/home/faulkner/folder/a/b/c/d/e/f/g/h/i/j/k/l
winscp> cd ../../../../../../../..
/home/faulkner/folder/a/b/c/d
winscp> cd ../../../..
/home/faulkner/folder
winscp> synchronize local -delete -preservetime
Comparing...
Local 'C:\Users\dan\Documents\folder\a\b\c\d\e\f\g\h\i\j\k\l' <= Remote '/home/faulkner/folder/a/b/c/d/e/f/g/h/i/j/k/l'
Synchronizing...
Local 'C:\Users\dan\Documents\folder\a\b\c\d\e\f\g\h\i\j\k\l' <= Remote '/home/faulkner/folder/a/b/c/d/e/f/g/h/i/j/k/l'
'C:\Users\dan\Documents\folder\a\b\c\d\e\f\g\h\i\j\k\l\m' deleted
winscp>
shortmort37

No, it deletes the folder:
C:\Users\dan>cd Documents


C:\Users\dan\Documents>mkdir folder

C:\Users\dan\Documents>cd folder

C:\Users\dan\Documents\folder>mkdir empty

C:\Users\dan\Documents\folder>"C:\Users\dan\AppData\Local\Programs\WinSCP\WinSCP.com"
winscp> open ...
Opening tunnel...
Searching for host...
Connecting to host...
Authenticating...
Using username "faulkner".
Authenticating with public key "Dan's MVPS" from agent.
Authenticated.
Connecting through tunnel...
Searching for host...
Connecting to host...
Authenticating...
Using username "faulkner".
Authenticating with public key "Dan's MVPS" from agent.
Authenticated.
Starting the session...
Session started.
Active session: [1] faulkner@127.0.0.1
winscp> cd /home/faulkner
/home/faulkner
winscp> mkdir folder
winscp> cd folder
/home/faulkner/folder
winscp> synchronize local -delete -preservetime
Using configured transfer settings different from factory defaults.
Comparing...
Local 'C:\Users\dan\Documents\folder' <= Remote '/home/faulkner/folder'
Synchronizing...
Local 'C:\Users\dan\Documents\folder' <= Remote '/home/faulkner/folder'
'C:\Users\dan\Documents\folder\empty' deleted
winscp>

Could it have something to do with the depth of the subfolder it's trying to delete? In my case, it has a depth of 11...
I will repeat this test, naming subdirs alphabetically up through "M".

Dan
martin

Thanks for all the tests.
Does WinSCP fail to delete any (empty) local directory?
So even if you do something trivial like this (in Windows Command prompt)
cd /d %USERPROFILE%\Documents
mkdir folder
cd folder
mkdir empty
"C:\Users\dan\AppData\Local\Programs\WinSCP\WinSCP.com"

And in WinSCP prompt:
open ...
cd /home/faulkner
mkdir folder
cd folder
synchronize local -delete -preservetime

Would it then fail to delete the empty folder?
shortmort37

By the way, it is now failing on a (new) empty directory:
Synchronizing...

Error deleting file 'I:\vps116136\faulkner\59forum\vendor\lusitanian\oauth\src\OAuth\Common\Http\Client'.
System Error.  Code: 5.
shortmort37

OK, so I tried the second suggestion first, so as to preserve the folder that WinSCP errors on:
Same way, if you re-run the synchronization after the error (from the same WinSCP instance), does it complete or fail the same way on the same folder?

It fails again, on the same folder. I then tried the first suggestion:
If you run the synchronization manually from WinSCP scripting console (so that WinSCP does not exit on the error) – can you delete the folder after the error from other application without exiting WinSCP? (to check if WinSCP has the folder locked somehow).

I am able to delete the folder using Windows Explorer without issue, while the WinSCP session remains open.

Dan
shortmort37

I get it! I supply each of the commands in example.txt to winscp>
It's running now.
shortmort37

Ah! I see I can get a winscp prompt if I do this:
I:\vps116136>C:\Users\dan\AppData\Local\Programs\WinSCP\WinSCP.com

winscp>

But I'm not sure where to go from there. If I fully qualify the path to WinSCP.exe and supply it with the /script and /log parameters, I get "Unknown command". I will continue to review the documentation...
shortmort37

I am unclear on how to run the WinSCP scripting console. Can you point me to an example?

I did turn off AV and repeated the experiment, to no avail.
martin

Thanks. Few things to test:

  • If you run the synchronization manually from WinSCP scripting console (so that WinSCP does not exit on the error) – can you delete the folder after the error from other application without exiting WinSCP? (to check if WinSCP has the folder locked somehow).

  • Same way, if you re-run the synchronization after the error (from the same WinSCP instance), does it complete or fail the same way on the same folder?

  • Try turning off your antivirus temporarily during the synchronization.
shortmort37

Yes, I:\ is a local 1 TB drive. My C:\ is a smaller SSD, and I save it for the OS and programs.
The log file is attached, untouched, so I have marked it private. The script was run with V6.5.3 of WinSCP.

Thanks
Dan
martin

Re: System Error Code 5 Redux

Thanks for your detailed report. What is the I: drive? Is it a local drive?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
shortmort37

System Error Code 5 Redux

As described elsewhere, I have been getting "Access Denied" with my nightly script for some time now. My script syncs my server running phpBB to my desktop. Typically, I get the error when attempting to delete a now empty directory because of an upgrade to phpBB. I have been manually deleting the directory, but this latest upgrade apparently remove a directory tree on the server, and so the error repeats on the next empty subdir, of which there appear to be many. So it's time to solve the problem.

I have followed the debugging guide described here, including the initial read/write test, but the error persists.

Relevant scripts and logs attached.
-Dan

Edit: example.bat was interactively executed in a CMD session, in directory I:\vps116136. I can, from this same user session, manually delete directories that report "Access Denied" when running the script.