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

Elwood

Yes I can. It's just one more scan of the root directory, whereas WinSCP already scans this directory when using synchronize, so it could be more elegant if WinSCP could do it.
But I see now that it's not even intended in the API (https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilew).

So I'll do it myself.

I then suggest to add a note in the description of the -delete switch (https://winscp.net/eng/docs/scriptcommand_synchronize), unless you want to answer such question again by someone else :-P

Thanks to all.
Elwood

Damn! You are right.
I am so surprised I can't delete this file from an MSDOS script, even if I run it as the domain administrator!

So as I want to fully understand, I spent some time on this and I found what blocks the file deletion. This is because the file has the ReadOnly attribute (you can see it on the Properties window, first tab).
So in MSDOS, using del myfile is not enough, you need to use del /F myfile.

So how can I do the equivalent with WinSCP? Any "-forcedelete" option? Or just "really delete" as it's what it is supposed to do anyway :-p

Thanks
martin

Can you create a Windows batch file that first (unsuccessfully) tries to delete the local file using winscp.com and synchronize local -delete and then deletes the same file using Windows del command? Post the batch file and its output and logs.
Elwood

You are right.
I report here because :

  • I run WinSCP "as administrator"
  • even without it (i.e. as normal user), using the Windows Explorer, I can delete the file that gives problems to WinSCP
  • I also reinstalled as suggested.

So I'm pretty sure, there is no problem on my side.
Oh and I didn't say: I have the same behaviour on many Windows (all of them are servers but they are probably different versions, 2016, 2019...etc.)
Guest

(I'm not the guest above.) But sometimes perms between an application and files are not as expected. It gets kind of crazy in certain situations. Like one might think that the application has the correct run permission when it doesn't or when another piece doesn't or maybe it doesn't to a certain storage device even if the files are. There's potential for all kinds of weird things.

There can in theory also be red herring situations where it might not actually be a perm issue at all such as one example that Martin gave where the file is locked by whatever as this isn't a perm issue. There's potentially other situations that can cause red herrings.

Perms are often not at the application's fault.

You should see if another application works or not. If it does work then there's something with this application and how its working or configured, and if it doesn't, then you have some other not WinSCP thing going on.

A log may or may not help much here. Depends.
Elwood

I just reinstalled WinSCP 6.3.4.14955 on a non-default directory, unchecking everything other than the program in the installer.
I executed my one line Winscp.com command and I still have:
System Error. Code: 5.
Access denied

If you want me to run a debug version of WinSCP, feel free to provide one. I'll be happy to help.
martin

@pferrucci: The file might have been temporarily locked by another application (e.g. by an antivirus), at the time WinSCP was trying to delete it.

Reinstallation as suggested by @Guest can indeed hardly help.
Elwood

There's nothing to install. I used the portable version. It's just 2 files, WinSCP.exe and WinSCP.com

Thanks
Guest

@pferrucci: You might try re-installing 6.3.1 over the current installation. That appears to have fixed it for me. (I actually re-installed the previous version first, but I'd give either way or both a try.)
pferrucci

I have the same problem. I am using version 6.3.1 using the commande line.
I am logged as mydomain\currentuser and the MSDOS console is opened as "administrator" so I should be able to delete any files.

I execute:
WinSCP.com /command "open myftp-details-here" "synchronize local -delete \Install /Install -filemask=|.stfolder/;.stversions/" exit

...
Synchronizing...

Error deleting file '\Install\one-directory\one-simple-file'.
System Error.  Code: 5.
Access denied

I used the icacls tool to look at the user permissions.
Here are the permissions on one-directory:
BUILTIN\Administrators:(I)(OI)(CI)(F)

NT AUTHORITY\System:(I)(OI)(CI)(F)
mydomain\currentuser:(I)(OI)(CI)(F)
OWNER:(I)(OI)(CI)(IO)(F)
BUILTIN\Users:(I)(OI)(CI)(RX)
BUILTIN\Users:(I)(CI)(S,WD,AD)

Here are the permissions on one-simple-file:
BUILTIN\Administrators:(I)(F)

NT AUTHORITY\System:(I)(OI)(CI)(F)
mydomain\currentuser:(I)(F)
BUILTIN\Users:(I)(RX)

If I delete one-simple-file from Windows explorer, it deletes it not even asking for an elevation.
martin

Re: Error Message

Sorry, I didn't read your response carefully.

I have sent you an email with a debug version of WinSCP to the address you have used to register on this forum.
BrunoJ

Re: Error Message

As I said previously.
martin

Re: Error Message

Ok. Did you try the downgrade?
BrunoJ

Error Disappeared

I reverted to V5.21.8 and was able to delete a file. I then re-installed V6.1 and was still able to delete a file. Gremlins?
BrunoJ

Error Message

That is the complete error message. See the attached image.
BrunoJ

Requested Steps


  1. Select file from display of local folder
  2. Press delete key
  3. Question appears: "Are you sure you want to move file '@DELETE THIS.jpg' to recycle bin?"
  4. Press OK button
  5. Error appears: "Error deleting file 'C:\...\@DELETE THIS.jpg'" (I have replaced the actual path in this display with an ellipses for privacy purposes. The path is correct.)
martin

Re: Local File Deletion Error

Thanks for your report.
Please provide us step-by-step instructions for reproducing the problem.
Do you get any error? Or what exactly happens?
I have no issues with deleting local files in WinSCP 6.
BrunoJ

Local File Deletion Error

Since upgrade to V6.1, I cannot manually delete local files using WinSCP. Should there be a PowerShell command for doing this?