A Batch File Can Not Delete From Server 2019
- Home
- Windows
- Windows Server
I have a pesky file on a server share that I cannot do anything with. I have full domain admin access. I cannot read, edit, delete modify permissions or read/take ownership of the file (including using takeown).
My googling has only really shown that a reboot is likely to make this file disappear as the file doesn't actually exist! It is likely that this file was previously deleted but it still shows up in explorer in both the share and the local drive.
I really do not want to reboot this server as it is our primary file server.
Any thoughts or advice?
Surely you'll need to reboot it at some point for Windows Updates?
The help desk software for IT. Free.
Track users' IT needs, easily, and with only the features you need.
13 Replies
Thanks Texkonc, I already tried that though :(
Windows provides the MoveFileEx API to rename or delete a file and allows the caller to specify that they want the operation to take place the next time the system boots, before the files are referenced. Session Manager performs this task by reading the registered rename and delete commands from the HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations value.
Please try using the "PendMoves" and "MoveFile" utility from Sysinternals.com.
Also, Can you check if any process has any open handle to that file ? You can use Process Explorer to find that.
Launch Process Explorer - Find - Find Handle or Dll (Specify the path of the file and click Search)
If you open a CMD and run a dir, what info does it show about that file ? Can you paste the output ?
Process Explorer states that the file process is System with a PID of 4.
I've run MoveFile, but this requires a reboot which I'm pretty sure will solve the problem anyway.
Cheers,
GG
GlennGuy wrote:
Process Explorer states that the file process is System with a PID of 4.
Try to run 'psexec -s cmd' and remove the file as NT AUTHORITY\SYSTEM without a rebooting.
Surely you'll need to reboot it at some point for Windows Updates?
Did you manage to take ownership? And is there an error message that you don't have suffitient rights at all? If yes, take ownership of the folder that contains the file if this will not cause other problems with other files.
If the file is locked from a proccess, the only thing you can do is to find the proccess and kill it. Of course you can reboot but I see this is not an option :)
Actually, is it a problem to schedule a reboot for next night for example?
Try to delete it via command line. Maybe there is a space at the start or end of the filename. For example, open its folder in cmd and view the contents of that folder, or try to display its name using the "Tab" key.
Id just pick a night/Out of Hours time and reboot the sucker. No point making more out of it than it really is.
Tully wrote:
Surely you'll need to reboot it at some point for Windows Updates?
Don't call me Shirley
As this is a Windows server, you probably need to reboot it weekly (or at least monthly) anyways. As long as the file isn't causing any issues other than tweaking your OCD, make a note (or a ticket!) so you don't forget about it and then just leave it be until the next scheduled reboot. After the reboot, check to see if the file is gone or accessible.
Brand Representative for Lepide
Hey,
Have you tried deleting them from a command prompt using
del "filename "?
Open a command prompt and remove the directory with:
rd /s "\\?\D:\bad\folder\path "
Hope this helps. Please update back as per the results.
Hi all, a reboot solved this issue! Thanks for your help.
This topic has been locked by an administrator and is no longer open for commenting.
To continue this discussion, please ask a new question.
A Batch File Can Not Delete From Server 2019
Source: https://community.spiceworks.com/topic/330716-cannot-delete-file