-1

I'm using Windows 7 with a VPN (Cisco AnyConnect) connection to an academic file share server. I copied a PowerPoint file from a local path to the server, and tried to delete the file on the server after no longer needing it.

It now shows up as a 0KB file, and I can no longer perform any actions on it except opening it as read-only. When I do open it as read-only, I receive the prompt "Unknown is working on \server\share_pathtofile. Do you want to open a read-only copy in the meantime?", and the file is empty (no slides, settings, etc). Here 'server_pathtofile' is the entire path of the problem file. I am positive no other user is accessing the file from another machine.

I have tried to overwrite it by Save As, using the same file name. Once I click Save, the save window closes and reopens without performing any action. This happens indefinitely if I continue to click Save. I can save the file with a different name on the server, and delete the file with a different name without issue.

I tried removing problem file using python through the Anaconda Spyder distro i use on my laptop.

import os

path = r"\\server\share"
file = r"\file.pptx"
#file = r"\test2.txt"
f = path + file
os.remove(f)

When i run it for the trouble file, it produces the error:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\server\share_pathtofile'

I looked into the shutil function, but don't think that'll be any more useful. I suspect the process handle for the PowerPoint file has been corrupted in some way. I thought to try and use Windows to perform the action directly through Powershell:

Remove-Item 'file.pptx'

But received a similar error:

Remove-Item : Cannot remove item \\server\share_pathtofile: The process cannot access the file '\\server\share_pathtofile' because it is being used by another
process.
At line:1 char:12
+ Remove-Item <<<<  'file.pptx'
    + CategoryInfo          : WriteError: (\\server...file.pptx:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

UPDATE 1: I tired postanote's suggestion by deleting through cmd.exe

pushd \\server\share
del /f "file.pptx"

The process cannot access the file because it is being used by another process.

I would've thought my inclusion of the powershell attempt to remove the file would've made this approach an obvious dead end. Shoudln't i be trying to find the so-called process that is telling Windows the file is still open?

Also, I was able to reproduce the same issue with a second ppt file and an excel file. They are not 0KB, but upon opening i get the same sort of prompt: "someone else is working on them and you can read-only".

I was making copies of the file within the same folder directory of the file share. My connection to the server got interrupted somehow, as Windows Explorer prompted me saying the connection to server share was able to be found. Upon closing the prompt, Windows Explorer did an unexpected refresh, the mapped drive was fine (i could navigate it without having to remap it), then suddenly I had two more problem files.

It is certainly not having the Windows Explorer preview pane open, i have never used that Explorer feature. Any ideas? We shouldn't let this file win...

T Walker
  • 330
  • 1
  • 3
  • 12

1 Answers1

0

PE will only look at process where it was started. Just like Task Manager, and if you are not accessing the file via some process (PowerPoint.exe), or know that in a shared file scenario, no one else has it locked, then you can take action on it.

This is not a PS specific issue (so not really a PS question) or anything related to process explorer and nothing to do with admin right on a server/workstation. If you have read/write/modify/delete permissions on a system / file share, you can act on that file of course.

It's a Windows proper issue. I've seen (and had this happen) this zero length files (depending on how they were created / copied) more than once, and they appear as impossible to delete.

The deal here, often Windows Explorer for such files won't even let you shorten the name via a rename effort. So, name length, odd characters, etc., are often the culprit(s)

So, you need to use cmd.exe and delete the file using the short DOS name. Just do a dir on the location where file is to get the short name and delete it.

dir /X
postanote
  • 15,138
  • 2
  • 14
  • 25
  • If you have Windows set to preview files in Win Explorer, it starts a hidden copy of PPT to produce the preview when you click on a PPT file. That can sometimes cause "file in use" errors, even when the file isn't open in a visible instance of PPT. In other cases, application errors can leave zombie copies of PPT open and holding files open. Try turning Preview off in Win Explorer, then restart Windows. If that doesn't solve the "file in use" problem, then it's likely due to some issue at the server end. – Steve Rindsberg Aug 04 '18 at 14:16
  • UPDATE 1: i edited the original post to address postanote's concerns of this not being related to Process Explorer in any way. I tried both commentors' suggestions with no luck, the file still exists. – T Walker Aug 04 '18 at 23:30
  • Sorry the cmd trip did not work for you, it has for me every time. At this point, I'd say fire up SysInternals handle.exe and see what it says regarding what/who has a lock on the files based on what you are seeing. – postanote Aug 05 '18 at 07:06