32

On Windows 7 Ultimate when I try to rename a new folder that is created (by copying usually), I usually get a "Folder is in use" error. I would have to wait a while before I would be able to modify the folder name. Files behave the same way too.

I am thinking that this is because I am sharing the folder, or library, via Homegroup Sharing. Does anyone who is running Windows 7 experience this as well? Is there any way to prevent the folder from becoming locked, so that I can modify it?

0

9 Answers 9

35
+200

Give LockHunter a try, which can unlock any handlers that may have locked your files or folders. Unlike similar freewares, it supports both 32 and 64-bit Windows.

It is a free tool to delete files blocked by something you do not know. LockHunter is useful for fighting against malware, and other programs that are blocking files without a reason. Unlike other similar tools it deletes files into the recycle bin so you may restore them if deleted by mistake.

  • Shows processes locking a file or folder
  • Allows to unlock, delete, copy or rename a locked file
  • Allows to kill locking process
  • Allows to remove locking processes from hard drive
  • Integrates in to Explorer menu
  • It deletes files into the recycle bin, so you may restore them if deleted by mistake
  • Supports both 32 and 64bit Windows
25

TL;DR? Read bold!

If you don't want external tools, or want a quick way to identify what process keeps your file in use. Then you can use a Windows Sysinternals tool called Process Explorer. You don't even have to extract a zipfile if you want to, just fetch the live version of Process Explorer from http://live.sysinternals.com/procexp.exe, which makes it easy to use this any time, any where, as long as you have internet (or if you had put it on an USB before you departed).

The bonus is that you can also use it for all your other Process related tasks...

process explorer

Process Explorer is meant as an IT Professional replacement of the Task Manager; amongst other alternatives like the Performance Monitor, Resource Monitor or an external tool like Process Hacker.

The feature you are looking for in this tool from Microsoft is as simple as it gets, it's CTRL+F which allows you to substring search for Handles or DLL files. If you would rather use your mouse and the menus, you can click on Find ➯ Find Handle or DLL.

Let's suppose that the Arial font files are in use, we can simply search for Arial and get to see that Instantbird and Firefox like to keep that font file in use. Let's suppose I would want to delete that file, I wouldn't be able to do so. Let's put a change to that and get rid of the Arial file. Don't do this at home...

Process Explorer Search

A simple fix would be to just close these two programs, while this works for Instantbird it seems that I can't shut down Firefox because I am writing this answer for you. And I don't want to risk losing my answer because of a cache timeout or a clipboard failure. So, I'm going to close all the Firefox handles to Arial.

Make sure Process Explorer is started as an administrator, then select File ➯ Show Details for All Processes

I simply select the handle in the search window and Process Explorer will automatically select Firefox and jump to the right entry in its main window. Make sure that you do this on a handle and not on a DLL, it might or might not be that you need to close the program if it were a DLL. It's time to close those handles so that I can remove the Arial font files for no reason; well, I can always restore them from a back-up...

Close handle

So, I simply right click on the relevant entries and click Close Handle.

And now, with a Firefox that has no Arial handles I post my answer; the font is loaded in anyway...

A command line alternative, which is only capable of listing them, is Handle; also written by Windows Sysinternals. You can also fetch a live version of it at http://live.sysinternals.com/handle.exe and use handle.exe followed by the sub string you want to search for.

Then use taskkill /PID 1234 /F /T where 1234 should be replaced by the PID of the process you got with Handle. Alternatively you can do it by image name with taskkill /IM instantbird.exe /F /T. Please note that /F forces termination and /T kills child prcoesses...

7
  • 1
    How about using Process Hacker instead :P
    – user541686
    Dec 23, 2011 at 3:40
  • @Mehrdad: Takes more steps to get there, and it lost the handles list notion. Which makes it a step further away when you want to see other entries while searching. That's what you get when you steal functionality without fully implementing it. For an IT Professional, Process Explorer is the tool of choice as Process Hacker is still in lack of some usage patterns and features like GPU usage; they rather add stuff for which low level programmers actually natively use WinDBG, which gives a far bigger set of functionality. No, I won't use a tool that steals and for which two more fit tools exist. Dec 23, 2011 at 3:50
  • I'm confused... what do you mean by "it lost the handles list notion"? Just bring up the program and do Ctrl-F (or Hacker->Find Handles or DLLs) to search, or double-click the process and go to the Handles tab... doesn't that do what you need? Also, GPU monitoring is also in there -- just download the Extended Tools plugin. What other functionalities are you referring to that you can't find in PH (or that aren't fully implemented)?
    – user541686
    Dec 23, 2011 at 4:10
  • 1
    It's the linkage between both lists that they forgot to steal. Dec 23, 2011 at 4:36
  • Oh I see what you mean... if you suggest it I'm sure they'll consider implementing it. :P
    – user541686
    Dec 23, 2011 at 4:46
4

Here's my current workaround:

I stopped using Teracopy as my default copy handler (but I have not yet uninstalled it). After copying a folder, I would go into it, and then back out. Then I could rename it. Else, I would just have to wait a while.

1
  • I haven't experienced this issue with Teracopy myself so this might have been patched by now. An alternative is to create the folder yourself, change the name and then just copying the contents... Dec 23, 2011 at 3:17
4

Short answer:

You can't.

Long answer:

It depends on the sharing mode, I believe. (I'm not referring to that kind of sharing -- I'm referring to the FILE_SHARE_DELETE kind of sharing.) If the file is opened with delete sharing mode, then theoretically you could write a program to:

  1. Open another handle to the file.

    Either try to open it normally, or try to use SYSTEM_HANDLE_INFORMATION to locate and duplicate the handle.
    Good luck with deadlock issues, etc. (which can be only correctly solved with a kernel driver).

  2. Rename it through that handle, using FILE_RENAME_INFORMATION.

I have no idea if your current sharing mode allows this... you'd just have to try and see.

3

Chances are that you're only experiencing this with folders that contain content that generates thumbnails (photos and the like). A lot of people have speculated that this is to do with indexing (which I'm not going to try to dispute), but in my experience this is usually down to thumbnail generation.

For example, in the bottom left-hand corner of your explorer window, if you select your problem-folder you should see the folder icon show a preview of the contents. It's kind of a nice addition to the GUI, but seems to be directly related to the problem.

Turn this off by going to ORGANIZE > FOLDER AND SEARCH OPTIONS > VIEW (tab) ... and then tick "Always show icons, never thumbnails". Click Apply/OK and you're done.

Try renaming that folder now. Do it several times in quick succession and hopefully you'll find that the folder renaming issue is gone.

1
  • 1
    Indeed, changing the path of a folder that's heavily used would be a bad idea. Dec 23, 2011 at 3:24
3

You can unlock a file using a freeware tool named Unlocker. You can download it from FileHippo.

If you've ever been unable to delete a file in Windows, and can't figure out what program's using it, Unlocker is the solution. Have you ever seen these Windows error messages?

  • Cannot delete folder: It is being used by another person or program
  • Cannot delete file: Access is denied
  • There has been a sharing violation.
  • The source or destination file may be in use.
  • The file is in use by another program or user.
  • Make sure the disk is not full or write-protected and that the file is not currently in use.

Unlocker can help! Simply right-click the folder or file and select Unlocker. If the folder or file is locked, a window listing of lockers will appear. Simply click Unlock All and you are done!

2

Often times if you're trying to rename videos, or folders that contain videos, explorer will be trying to make thumbnails using media player, which locks the file or directory. If you sit there for thirty seconds then try again, it will work. The only way I've found to avoid this is to disable thumbnails of media files, but that's not really ideal.

3
  • 1
    This was the solution, for me: Disable Creating Thumbs.db • Click Start, type Folder Options into Search bar and press Enter. • Switch to View tab • Check “Always show icons, never thumbnails” box.
    – iokevins
    Apr 14, 2011 at 16:32
  • Note: experienced this issue on a network share; and this will disable thumbnail generation, I believe?
    – iokevins
    Apr 14, 2011 at 16:33
  • This is particularly strange, but I think it's probably the result of slow thumbnail generation. Usually some other explorer extension plays a role in slowing the process down, but it isn't much of a problem as waiting and disabling are two easy solutions... Dec 23, 2011 at 3:23
0

This is likely to be caused by one of two things:

  1. An AV program scanning the files that have just been created.
  2. The Windows 7 indexing function processing the newly created file/folder.

I had this same trouble when I installed Windows 7 and was able to tweak the search/indexing functionality to not process files and that resolved it. On the start button type index into the Search programs and files option. This should bring up Indexing Options as one of the items. Open that program and then select the Users location and click modify. In here I deselected the folder that holds most of my files.

The downside of this is that your files are not indexed - the upside is you actually get to work with them when you want - not when the system lets you.

1
  • 2
    The Search Indexer is fairly quickly and is programmed in such way that it doesn't interrupt with your work, it even schedules itself to run during idle times. It should in no case put a file or folder in use, that's just speculation. Some anti virus scanners are more likely to interfere. It could be that your virus scanner is scanning all the files that the Search Indexer is trying to access... Dec 23, 2011 at 3:28
0

Make sure that the Application Experience service is not disabled. If so, set it to manual:

Run dialog (or command prompt):

  > sc config AeLookupSvc start= demand

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .