Local File Deletion Error

Advertisement

BrunoJ
Joined:
Posts:
5

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?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

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.

Reply with quote

BrunoJ
Joined:
Posts:
5

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.)

Reply with quote

Advertisement

martin
Site Admin
martin avatar

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.

Reply with quote

Advertisement

pferrucci
Guest

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.

Reply with quote

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.)

Reply with quote

martin
Site Admin
martin avatar

@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.

Reply with quote

Advertisement

Elwood
Joined:
Posts:
6

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.

Reply with quote

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.

Reply with quote

Elwood
Joined:
Posts:
6

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.)

Reply with quote

martin
Site Admin
martin avatar

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.

Reply with quote

Advertisement

Elwood
Joined:
Posts:
6

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

Reply with quote

Elwood
Joined:
Posts:
6

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.

Reply with quote

Advertisement

You can post new topics in this forum