Wednesday, August 24, 2005

Using Sysinternal PsTools to find what has locked that process

[This was originally posted at http://timstall.dotnetdevelopersjournal.com/using_sysinternal_pstools_to_find_what_has_locked_that_proce.htm]

Every get one of those frustrating errors "Cannot access file because it is being used by another process"? For example, you may be trying to delete or rename a file, but this error message won't let you. Sometimes it is as simple as closing an application that obviously has locked that file, but sometimes it's just more complicated - perhaps some service (which has no GUI, and therefore may be less intuitive) has locked the file. Ideally you could just click the file in Windows Explorer and it would tell you what locked the file and what to do.

There is a solution - Sysinternals provides a free tool, Process Explorer, that lets you find all the processes accessing a file. The tools requires no MSI; you can directly copy it to your machine and run it. It's like Task Manager on steroids (in a good sense).

Initially one may make sure that they don't have the file open in some sort of editor, but the problem may persist even if everything is closed. Go to Find > Find Handle, and type in the name or directory of the file. Click search, and it will show you all processes accessing that file. You can now kill those processes such that you can delete the file.

This is actually very educational - you'll see that IIS, other instances of Windows Explorer, certain background services, or apps that you wouldn't think of, all can lock files.

2 comments:

  1. Mỗi loại ghế văn phòng cho cônh ty doanh nghiệp đều khác nhau tùy thuộc vào nhiều yếu tố khác nhau. ChoNên lựa chọn mua ghế văn phòng nào hợp với bạn
    khi chọn mua bàn làm việc hay ghế làm việc thì việc đầu tiên bạn nên biết là cácTiêu chí nên biết chọn mua ghế văn phòng
    Khi chọn mua mẫu ghế cho công ty doanh nghiệp tại văn phòng làm việc bạn nên quan sát và chú ý việcChọn mua mẫu ghế văn phòng cho công ty doanh nghiệp
    Khi chọn mua ghế văn phòng làm việc thì bạn nên quan tâm đến việcNên lựa chọn mua ghế văn phòng nào hợp với bạn
    Ghê văn phong nói riêng và các sản phẩm nội thất văn phòng nói chung thì đều có các ưu điểm riền va cung tìm hiểuNhững ưu điểm ghế văn phòng làm việc
    Ghế xoay văn phòng làm việc tại văn phòng công ty bạn nên quan tâm tới các tiêu chí sauChọn mua ghế xoay làm việc tại văn phòng

    ReplyDelete
  2. Every time you stop outside that glass window showing those glittering, stunning Rolex watches. This is a heartfelt desire to wrap your wrist with this most well- known name,Svizzeri perfetti Orologi. There is good news for you. Now, you need not to spend those big bucks for acquiring your dream watch. Your answer is Replica watches. Yes come here buySvizzeri Repliche Orologi

    ReplyDelete