Yeah, this error is a pain — you're trying to install a driver and Windows just goes "nope." But don't worry, it's not your hardware. It's a registry thing. Let's fix it.
The Quick Fix – Clear the Class Keys
Most of the time, the problem is a leftover or corrupted entry under HKLM\SYSTEM\CurrentControlSet\Control\Class. A bad install or an old driver leaves garbage there, and Windows refuses to use it.
Here's what you do, step by step:
- Open Device Manager (Win + X → Device Manager).
- Find the device that's failing. It's likely under Other devices with a yellow bang.
- Right-click it → Uninstall device, and check the box "Delete the driver software for this device" if it appears.
- Now open Regedit (Win + R, type regedit, Enter).
- Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class. - Look for a key that matches the device's GUID. For example,
{4d36e968-e325-11ce-bfc1-08002be10318}is display adapters. If you see a key with the exact error's class GUID (or one that looks like{xxxxxx-...}with weird values likeClassorClassGUIDmissing), right-click and Delete it. - Restart your PC.
Then install the driver again. Usually it works. If not, we have the target fix below.
Why does this work?
The error SPAPI_E_INVALID_CLASS specifically means the setup API can't find a valid class definition for the device. When you delete the corrupt registry key, Windows rebuilds it from the INF file during the next install. So the driver gets a fresh class. Simple, right?
The Target Fix – Point to the Right INF
Sometimes the registry is fine, but the driver package itself has a typo or a mismatched class GUID in its INF file. That's common with older drivers or beta builds.
Here's how to force Windows to use the correct INF:
- Download the driver again from the manufacturer. Don't use the one from Windows Update – it's often stripped down.
- Extract the driver files to a folder like
C:\Drivers\MyDriver. - Open Device Manager, right-click the problem device, and select Update driver.
- Choose Browse my computer for drivers.
- Click Let me pick from a list.
- Click Have Disk → Browse → select the .inf file from the extracted folder.
- If you see a warning about a mismatched class, click Yes to install anyway.
That usually bypasses the class validation. But if the INF is truly broken, you'll need to edit it manually — not fun, but here's the short version: open the INF in Notepad, find the [Version] section, and look for Class= and ClassGuid=. Compare them with the device's actual type. If they're blank or wrong, replace with the correct GUID from Microsoft's list (Google it, it's long). Then save and try again.
Less Common Variations
Here are a few other scenarios I've seen that give the same error:
- USB device after wake from sleep – The class key gets corrupted during power events. Unplug the device, restart, and plug it back in. No registry edits needed.
- PCIe card on Windows 10 1809 – I've seen this with old sound cards (like Creative X-Fi). The fix is to manually add the class GUID under the same registry path, but that's risky. Better to force the INF method above.
- Virtual device from VMware – If you're installing VMware tools and get this, it's a known bug. Update VMware Tools to the latest version, or disable the virtual device in the VM settings and re-enable it.
Prevention – Don't Let It Happen Again
This error usually comes back if you keep installing drivers from unknown sources. Stick to the manufacturer's website or Windows Update. Also, avoid using those "driver updater" tools that scan your PC — they often mess up the registry.
One more thing: before installing any driver, create a system restore point. If something breaks, you can roll back in minutes.
And if you're a sysadmin like me, make a habit of cleaning leftover drivers with pnputil /delete-driver after uninstalling a device. Here's a quick command:
pnputil /enum-drivers
Find the ones with oem*.inf that are not in use, then remove them with:
pnputil /delete-driver oemXX.inf /force
This keeps your driver store clean, which prevents class corruption in the first place.
That's it. Fix, understand, prevent — you're good to go. If it still fails, then you've got a bigger hardware problem, but that's rare.