Skip to main content

Overview

File Locksmith helps you discover which processes are locking a file or folder, preventing deletion, moving, or modification. It integrates directly into File Explorer’s context menu, allowing you to quickly identify and terminate locking processes.
Terminating processes may result in data loss. Always save your work before ending processes.

Activation

1

Enable File Locksmith

Open PowerToys Settings and enable File Locksmith
2

Right-Click File/Folder

In File Explorer, right-click on a locked file or folder
3

Select 'What's using this file?'

Choose the File Locksmith option from the context menu
4

View Locking Processes

A window appears showing all processes using the file

Key Features

Process Detection

File Handle Detection

Identifies processes with open file handlesShows read/write access modes

Folder Monitoring

Detects processes accessing foldersIncludes files within directories

Multiple Files

Check multiple files simultaneouslySelect multiple files in Explorer

Process Details

Shows process name, PID, and userFull path to executable

Context Menu Integration

Seamless File Explorer integration:
// Explorer command registration
class FileLocksmithContextMenu : public IExplorerCommand
{
public:
    // Display in context menu
    HRESULT GetTitle(IShellItemArray* items, LPWSTR* name)
    {
        *name = L"What's using this file?";
        return S_OK;
    }
    
    // Handle menu item click
    HRESULT Invoke(
        IShellItemArray* selection,
        IBindCtx* bindContext
    );
};
Menu location:
  • Right-click file/folder
  • “Show more options” (Windows 11)
  • “What’s using this file?” option

Process Information Display

Detailed information about locking processes:
  • Process Name: Application name
  • Process ID (PID): Unique process identifier
  • User: Account running the process
  • File Path: Full path to executable
  • Access Type: Read, Write, or Read/Write
  • Handle Count: Number of open handles

Process Termination

Gracefully terminate a process:
  1. Select process in File Locksmith window
  2. Click “End Process” button
  3. Confirm termination
  4. Process receives termination signal
  5. File/folder is unlocked
Note: Similar to Task Manager’s “End Task”

Configuration

Settings

Minimal configuration required:
enabled
boolean
default:"false"
Enable or disable File LocksmithControls context menu integration
extended_context_menu
boolean
default:"false"
Show in extended context menu onlyRequires holding Shift while right-clicking

Extended Context Menu

Reduce context menu clutter:
  • Disabled: Always visible
  • Enabled: Only visible when holding Shift
Windows 11 note: File Locksmith appears under “Show more options” by default

Use Cases

File Deletion Issues

Common scenario:
Error: The action can't be completed because
the file is open in another program
Solution:
  1. Right-click file → “What’s using this file?”
  2. Identify locking process
  3. Save work in that application
  4. End process
  5. Delete file successfully
Application closed but file still locked:
  • Background process still running
  • Crash left handles open
  • Service holding file
Use File Locksmith to:
  1. Find zombie process
  2. Terminate lingering handles
  3. Clean up properly

Development Scenarios

1

DLL Rebuild Issues

Cannot rebuild project due to locked DLL:
Error: Cannot copy 'MyLibrary.dll' because
it is being used by another process
Identify: Test application still running
2

Log File Access

Cannot delete or move log files:
  • Application still logging
  • Log viewer has file open
  • Background service writing logs
Find: Which process is logging
3

Database Files

Database file locked:
  • SQLite .db file in use
  • Multiple connections open
  • Crashed application
Solution: End all database connections

System Maintenance

Folder Deletion

Cannot delete folder with locked filesFind all processes using folder contents

USB Drive Ejection

“Device is in use” errorIdentify processes accessing USB drive

File Moving

Cannot move files between foldersDiscover hidden locks

Update Installations

Installer cannot replace filesEnd processes before updating

Media Production

Video file locked by:
  • Video player in background
  • Encoder still processing
  • Preview generator
Use File Locksmith to find and close

Network Shares

Files on network drives:
Scenario: Shared folder file locked

File: \\Server\Share\Document.docx
Issue: "File is in use by another user"

File Locksmith shows:
  - Remote user's process
  - Network session details
  - Cannot terminate remote process
  
Solution:
  - Contact user to close file
  - Administrator can force-close from server

Technical Details

Architecture

Handle Detection

File Locksmith uses Windows APIs to enumerate handles:
// Handle enumeration
NTSTATUS NtQuerySystemInformation(
    SYSTEM_INFORMATION_CLASS SystemInformationClass,
    PVOID SystemInformation,
    ULONG SystemInformationLength,
    PULONG ReturnLength
);

// Query handle information
NTSTATUS NtQueryObject(
    HANDLE Handle,
    OBJECT_INFORMATION_CLASS ObjectInformationClass,
    PVOID ObjectInformation,
    ULONG ObjectInformationLength,
    PULONG ReturnLength
);
Process:
  1. Enumerate all system handles
  2. Filter handles of type “File”
  3. Query handle name/path
  4. Match against target file
  5. Return owning process information

Components

ComponentPurposeLocation
FileLocksmithCLICommand-line interfacesrc/modules/FileLocksmith/FileLocksmithCLI
FileLocksmithContextMenuExplorer integrationsrc/modules/FileLocksmith/FileLocksmithContextMenu
FileLocksmithLibCore handle detectionsrc/modules/FileLocksmith/FileLocksmithLib
FileLocksmithUIUser interfacesrc/modules/FileLocksmith/FileLocksmithUI

CLI Usage

File Locksmith can be used from command line:
# Check what's using a file
FileLocksmith.exe "C:\Path\To\File.txt"

# Output: List of processes with PIDs
# Process: notepad.exe (PID: 1234)
# User: DOMAIN\Username
# Path: C:\Windows\System32\notepad.exe
Source: src/modules/FileLocksmith/FileLocksmithCLI/main.cpp

Process Termination

Multiple termination methods:
// Graceful termination
bool TerminateProcess(DWORD processId)
{
    HANDLE hProcess = OpenProcess(
        PROCESS_TERMINATE, 
        FALSE, 
        processId
    );
    
    if (hProcess)
    {
        // Send termination signal
        BOOL result = ::TerminateProcess(hProcess, 0);
        CloseHandle(hProcess);
        return result;
    }
    return false;
}

// Process tree termination
void TerminateProcessTree(DWORD processId)
{
    // Find child processes
    auto children = GetChildProcesses(processId);
    
    // Terminate children first
    for (auto child : children)
    {
        TerminateProcessTree(child);
    }
    
    // Terminate parent
    TerminateProcess(processId);
}

Keyboard Shortcuts

In File Locksmith Window

ShortcutAction
Shift+Right-ClickShow context menu (if extended menu enabled)
EnterEnd selected process
DeleteEnd selected process
EscClose window
F5Refresh process list

Troubleshooting

Check:
  • File Locksmith is enabled in PowerToys Settings
  • On Windows 11, check under “Show more options”
  • If extended menu enabled, hold Shift while right-clicking
Fix:
  1. Restart File Explorer
  2. Disable and re-enable File Locksmith
  3. Restart PowerToys
  4. Check shell extension registration
Possible causes:
  • System/kernel process holding file
  • File locked by Windows itself
  • Network share lock (remote process)
  • Permissions prevent detection
Solutions:
  1. Run PowerToys as Administrator
  2. Check Windows Event Viewer for file access logs
  3. Use Process Explorer for deeper analysis
  4. Restart computer to clear all locks
Reasons:
  • Insufficient privileges (need admin)
  • System-critical process
  • Process already terminating
  • Protected process
Try:
  1. Run PowerToys as Administrator
  2. Use “End Process Tree” option
  3. Use Task Manager with admin rights
  4. Restart computer
Protected processes: Cannot be terminated (e.g., csrss.exe, System)
Check:
  • Process actually terminated (check Task Manager)
  • File handle cleanup may take a moment
  • Another process opened file
  • File system sync delay
Steps:
  1. Wait a few seconds
  2. Re-run File Locksmith
  3. Check for additional locking processes
  4. Refresh File Explorer (F5)

Limitations

Cannot terminate remote processes:For files on network shares, File Locksmith shows which remote computer/user has the file open but cannot terminate processes on remote machines.Workaround: Administrator must close file from server side or use server management tools.

Kernel-Mode Locks

Some file locks are held by kernel drivers:
  • Antivirus scanners
  • File system filters
  • Disk encryption software
  • Backup agents
These may not appear in File Locksmith’s process list.

Permission Requirements

To terminate processes:
  • User processes: No special permissions
  • Other users’ processes: Administrator rights
  • System processes: Administrator + may be protected
  • Services: Administrator + service control rights

See Also