How to Recover Locked Windows 7 Files
How to Recover Locked Windows 7 Files
One of my Windows 7 students shared a scenario that has several possible root causes, and therefore several possible repairs.
The scenario: a program and file in use are closed. Attempts to move the file indicate that the file is still open and Windows will not allow a move or rename of the file.
Microsoft provides only modest directions for identifying and recovering locked files. Why can’t I delete a file or folder?
Although the specific program was not identified, one of the more common issues associated with Microsoft Office applications, amongst others, is the creation of temporary files that may remain if the application terminates improperly. For instance, it is always best to use the File-Close or Quit Application menu options rather than just resorting to program termination using the red “X” on the application window.
Graham Mayor provides a thorough overview for resolving file locks when Word 2002, 2007 or 2010 terminates improperly. What to do when Word crashes? The key in this instance is to locate the system temporary folder (identified by %temp%) and to remove all the associated temporary files that may result in a file lock scenario. Do not just look for folders named ‘temp’ or you may not locate the files you seek.
Using Restore Points to Recover a File
Before resorting to any manual file removal or cleanup, I strongly recommend creating a system backup or using the Windows 7 System Protection option to create a Restore Point. Type “Restore Point” in the Start search box and select ‘Create a Restore point’. The System Properties > System Protection panel will launch.
Prior to file deletion, Configure System Protection. You want to select Restore System Settings and Previous Versions of Files as seen below. Then Create a Restore Point. If you accidentally delete an important file, you now have a simple means to restore it.
If you already have restore points created, then one method to recover and unlock a file is to use of the Restore Previous File Version feature in Windows Explorer. Launch Windows Explorer and open the folder containing the locked file. Alt-Click (right mouse button) on the file and select restore Previous Versions. If you have created a restore point, and the file has been altered, you may select it from the list of available file versions.
Once you have selected a file, you may open it and then relocate it using the Save-As option, copy it to an alternate location, or restore it. Restoring the file may not correct all file lock situations, though is a reasonable starting point.
When using Windows 7, don’t forget about file permissions and the role played by User Account Control.
Even if you are a help desk technician or system administrator, if you are not the owner of a file you may not have the permission to modify, move, or delete a file when running as a standard user. When debugging file lock problems, make certain that you launch Windows Explorer by typing ‘Windows Explorer’ in the Search box, then use Alt-Click to Run as Administrator. If you merely launch Windows Explorer from the Quick Launch bar or by selecting Computer you will be running in Standard User mode.
Once in Windows Explorer you may check the file properties for Security settings including modify permission. You may also take ownership under the Advanced Settings button though want to be extremely cautious about taking Ownership in Windows 7, since this may disrupt the creator’s permissions. If the file is encrypted, NEVER attempt to take control unless your enterprise has an encryption recovery policy in place and validated.
You can also attempt the Previous Versions of Files option for file recovery through the file Properties panel.
File permissions can also affect server side folders. Remember that file security permissions are NTFS, not Operating System, based. You will need the File Server administrator to check file permissions if a file is locked on the server side.
If a user has locked a file through improper application termination on the client side, you may still be able to acquire a copy of the file from the file server. Copy is the key concept here. You will have to assist on the client (either locally or through remote access) to clean up any local %temp% files that may be preventing file access for the client.
If the file is locked due to improper application termination, you may be able to clear the file lock by locating the running process within Task Manager, and ending the process tree. Remember that you may launch multiple instances of a program as unique shells in Windows 7. Although you may be able to launch a second or third instance of Microsoft Word, for example, the locked file may be associated with process residue from an improperly terminated instance of the application. The Microsoft recommendation is to reboot the system, though we teach never to use a system reboot to solve a problem without justification. You want to do your research and confirm that a process is locking the file before rebooting. If the process is set to Auto-start or is part of a Startup group, merely rebooting the system will not resolve the problem.
While in Task Manager, you might also check to see if there are other users attached to the system. Concurrent or alternate use of the file is another cause for the file to be locked. Merely select the Users tab within task manager. You should only see one local session, and potentially one remote session if you are using Remote Desktop or Remote Assistance to debug the file issue.
For a more sophisticated file diagnostic tool, you want to use the Microsoft Process Explorer from Sysinternals. You want to acquire it through TechNet.
Process Explorer will enable you to thoroughly research which files, handles, and DLLs are open or locked by a specific process. Process Explorer should help you to specifically identify why a particular file is locked.
NOTE: Make sure you have permissions to install applications on the client, and that you run the installation and run the tool as an Administrator. User Account Control does not typically want a standard user implementing a tool with this capability.
The Technet download site offers several links to other tools by Mark Russinovich, the tools author, as well as an administrator’s reference that may also be useful.
Use of Process Explorer to research a file lock problem is fairly straight forward. Joe Medeiros of Javelin offers a quick overview.
Slow Process Termination and Integration Tools
One other thought before I close this blog.
Several Windows 7 applications stay resident for minutes after they are closed. Even if you close them properly. For instance, Internet Explorer may continue to run for 5 or 10 minutes after you close all the Internet Explorer Windows.
If the application incorporates add-ons, uses Windows or Microsoft Update to receive updates and patches, or integrates multiple applications, then you may have to wait several minutes before you can access files that were locked during use by the application.
For instance, I keep Evernote running on my system to capture student questions, random thoughts, or articles I find while teaching or researching. Evernote integrates with my browser, mail client, Microsoft Word and other applications. If I snapshot file content and place it into Evernote, then the file may be marked as in use even after I close the initial application. With the growing number of workflow management and cloud based solutions deployed today, you will want to assure that you close all running applications and then confirm that they are closed using Task Manager before pulling your hair out identifying how a file may be locked.
As with all good troubleshooting efforts, isolation of the issue requires eliminating as many factors as possible, and that includes properly terminating all but essential applications during the investigative and repair process.
You May Also Like
In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.
In this session, we are going to look at how to subnet a Class B address into multiple network segments using what's called The Magic Box. Let's run through this real quick.
In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.