Quick answer: Run pnputil /enum-drivers to find the locked driver package, then pnputil /delete-driver oemXX.inf /force to remove it, then reinstall the driver.
That error code 0X800F0213 (SPAPI_E_DEVINFO_DATA_LOCKED) is Windows telling you that the driver package you're trying to install is already in use — specifically, the device information element is locked. This usually happens when you've installed a driver before, then tried to update or replace it, but Windows still has a file handle open on the old driver's INF or sys file. It's common after a failed driver update, or when you uninstall a device but Windows keeps the driver package in its store.
I've seen this on Windows 10 and 11, especially with graphics cards and USB devices. The culprit is often a leftover driver package that's been marked as "in use" by the system. You can't just delete it from Device Manager — you have to force Windows to let go.
Here's how to fix it, step by step.
Fix 1: Use pnputil to delete the locked driver package
- Open Command Prompt as administrator. Press Win, type cmd, right-click Command Prompt, and select Run as administrator.
- Type
pnputil /enum-driversand press Enter. You'll see a list of installed driver packages. Look for the one that matches your device — check the INF name and the driver provider/date. - Once you identify the right package (note the
oemXX.inffile name), type this command to delete it:pnputil /delete-driver oemXX.inf /force(replaceoemXX.infwith the actual file name). The/forceflag is critical — it bypasses the lock. - You should see "Driver package deleted successfully." If you get an error about the driver being in use, try rebooting into Safe Mode (with networking) and repeat steps 1-3.
- After deletion, restart your PC. Then reinstall your driver from the manufacturer's website or via Device Manager.
After running the delete command, try reinstalling the driver. The error should be gone.
Fix 2: Clean up the driver store manually (if pnputil fails)
Sometimes pnputil won't let go, even with /force. In that case, you need to clear the driver store cache. This is a bit more invasive, but it works.
- Open File Explorer and go to
C:\Windows\System32\DriverStore\FileRepository. This is a protected folder, so you may need to copy the INF file to your desktop first if you can't access it directly. - Look for a subfolder that matches your driver (for example,
nv_dispi.inf_amd64_xxxfor NVIDIA). Note the exact folder name. - Open an elevated Command Prompt and run:
takeown /F "C:\Windows\System32\DriverStore\FileRepository\foldername" /R /D Y(replacefoldername). This gives you ownership. - Then run:
icacls "C:\Windows\System32\DriverStore\FileRepository\foldername" /grant administrators:F /T. - Now delete that folder using File Explorer or
rmdir /S /Q pathin Command Prompt.
This is a last resort — be careful. Only delete the specific folder associated with the device you're having trouble with. Deleting the whole FileRepository folder will break your system.
Fix 3: Use Device Manager to uninstall and reinstall the device
Sometimes the lock is on the device instance itself, not the package. Here's how to reset that.
- Press Win + X and select Device Manager.
- Find your device (it may show a yellow warning icon). Right-click and select Uninstall device — check the box "Delete the driver software for this device" if it appears. If it doesn't, that's fine.
- Now, click the Action menu and select Scan for hardware changes. Windows will re-detect the device.
- If it comes back with the same error, reboot and repeat, but this time skip the uninstall and just do a scan.
This works best if the lock was temporary — for example, if a USB device was disconnected mid-install.
Fix 4: Update the driver using Windows Update (as a workaround)
If you just need the driver working and don't care about the latest version, you can let Windows Update handle it.
- Go to Settings > Update & Security (Windows 10) or Windows Update (Windows 11).
- Click Check for updates. If Windows finds a compatible driver, it'll install it automatically.
- Once it's installed, you can then update to the latest version from the manufacturer, and it won't hit the lock.
This is a good fallback if the manual methods seem too risky.
Prevention tip
The real fix is to never interrupt a driver installation. Wait for the "Successfully installed" message. If you're updating a graphics driver, uninstall the old one first using Display Driver Uninstaller (DDU) in Safe Mode — that clears the driver store cleanly. Also, avoid using third-party driver updater tools that force installs; they're the usual cause of this kind of lock.
If you're a developer testing drivers, you should use the Windows Driver Kit's InfDefaultInstall in a test environment, not on your daily driver.