SPAPI_E_NO_DEVICE_SELECTED (0X800F0211) - No Device Info Element Selected
This error hits when a driver install tool or script tries to access a device info set without selecting a specific device element first. Root cause: wrong API call order or corrupted device node.
You're running a driver install script or a device management tool — maybe pnputil, a custom SetupAPI app, or something like Dell Command Update — and it throws SPAPI_E_NO_DEVICE_SELECTED (0X800F0211). The exact message: There is no device information element currently selected for this device information set. This almost always hits when the tool expects a device to be pre-selected in the device information set, but nothing's set. Happens most often after a partial device uninstall, a failed driver rollback, or when you're running a script that calls SetupDiCallClassInstaller without a proper SetupDiSetSelectedDevice call first.
What's Actually Going On
Windows uses a data structure called a device information set to track all devices in a class. Inside that set, you've got individual device information elements — one per device. To perform operations like installing or removing drivers, you need to tell Windows which element you're working on. That's SetupDiSetSelectedDevice. If you skip that step or the element gets invalidated (like the device disappears mid-operation), you get 0X800F0211.
- Typical trigger: A script uses
SetupDiGetClassDevsto get a device list, loops through devices, but never sets one as selected before calling an install or remove API. - Another common cause: The device node (devnode) went stale — Windows removed the device (or it failed) between when you enumerated it and when you tried to act on it.
- Less common but real: Corrupted driver store files. This one's rare but I've seen it after a botched Windows Update.
The Fix: Step by Step
Don't bother reinstalling the whole driver stack yet. That's overkill. Try these in order.
Step 1: Re-select the Device in Device Manager
- Open Device Manager (
devmgmt.msc). - Find the device throwing the error. It'll usually have a yellow bang or show as unknown.
- Right-click it and select Uninstall device. Check Delete the driver software for this device if you want a clean slate.
- Restart the machine.
- Let Windows re-detect the device on boot, or manually scan for hardware changes (Action menu > Scan for hardware changes).
This clears any stale device info elements. I'd say this fixes 60% of cases.
Step 2: Use PnPUtil to Force a Rescan
If Step 1 didn't do it, the device node is probably stuck. Open an elevated Command Prompt (Run as Administrator) and run:
pnputil /scan-devices
Then:
pnputil /enum-devices
Check if your device shows up with a Problem code. If it's CM_PROB_NOT_CONFIGURED (0x1C) or CM_PROB_FAILED_INSTALL (0x1F), you're dealing with a deeper issue. Next step:
Step 3: Check for Corrupted Driver Store — Use DISM
I've seen corrupted driver store entries cause this error when tools can't enumerate the right elements. Run this in an elevated Command Prompt:
DISM /Online /Cleanup-Image /RestoreHealth
Then run sfc /scannow after. Reboot. Try the original tool again.
Step 4: If You're Writing a Script — Fix the API Call Order
For devs and advanced admins: the proper sequence is:
SetupDiGetClassDevs— get the device info set.SetupDiEnumDeviceInfo— enumerate to a specific index.SetupDiSetSelectedDevice— this is the step people miss.- Then call
SetupDiCallClassInstalleror whatever operation.
If you're using PowerShell with Get-PnpDevice and then Disable-PnpDevice or similar, the cmdlets handle this internally. But if you're calling WMI or CIM methods directly, double-check the Win32_PnPEntity instance you're using is still valid (not orphaned).
Still Failing? Check These
- Device is physically disconnected or failed: For USB devices, try a different port. For internal devices (like a NIC), check BIOS for whether it's disabled.
- User account permissions: The tool must run as Administrator.
SetupDiAPIs demand elevation. - Antivirus interference: I've seen Bitdefender and McAfee block driver installs in a way that leaves devices in a half-configured state. Disable real-time protection temporarily and test.
- Windows Update pending: Sometimes a pending update holds a device in a transitional state. Run
wuauclt /detectnow(or just check for updates manually) and reboot.
The root of this error is almost always a sequence gap — something that should have set the device element didn't. Clean the state, reselect the device, and you're usually good. If you're still stuck after this, it's probably a hardware-level issue or a corrupted driver store that needs a system restore point rollback.
Was this solution helpful?