Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 2008 R2 - Kernel (System Process PID=4) is locking files and folders

Windows 2008 R2 - Kernel (System Process PID=4) is locking files and folders for a long time. For example when deleting a file, the file may remain locked for 1 minute or more and only after that be deleted. On another occasions I encountered files or folders I could not delete. ProcMon showed that the System Process was holding a handle to those resources for a couple of minutes and then released them None of the resources I mentioned were system resources, only files and folders installed be me and handled by my applications.

like image 548
Dani Avatar asked Dec 07 '10 15:12

Dani


People also ask

How do I unlock a locked file in Windows server 2008?

Open AdministrativeTools -> Share and Storage Management. From the Actions pane, click Manage Open Files. Here you are able to see all locked files and folders on this server. To clear a lock, select the relavent file and click “Close Selected”.

How do you find out which processes are locked up?

Microsoft/SysInternals Process Explorer - Go to Find > Find Handle or DLL. In the "Handle or DLL substring:" text box, type the path to the file (e.g. "C:\path\to\file. txt") and click "Search". All processes which have an open handle to that file should be listed.

Why is system locking a file?

A fundamental of file systems since their inception has been their locking mechanisms. These exist so that different users and applications working on the same file (or region of a file) simultaneously cannot cause conflicts that result in inaccuracies and inconsistencies in the data.


2 Answers

As Dani has already mentioned in the comment:

It's a bug in Windows 7 and likely in Windows Server 2008 (possibly 64bit versions only). It surfaces when you disable Application Experience service.

Re-enabling this service has fixed this problem for me.

A bit more info here as to why it's causing a problem.

List of other SO questions which seem to be related:

  • Visual Studio output file permissions?
  • Under which circumstances does the System process (PID 4) retain an open file handle?
like image 112
Maiku Mori Avatar answered Oct 12 '22 17:10

Maiku Mori


Files accessed through a share will be locked by the system process (PID 4).

Try opening compmgmt.msc -> System Tools -> Shared Folders -> Open Files to see if the locked file is listed there

See also the sysinternals forum for a way to replicate this.
Not all applications lock files when they are opened, Excel however does...

like image 26
janv8000 Avatar answered Oct 12 '22 18:10

janv8000