Quick answer: Rename your PC so it contains only letters, numbers, and hyphens (no spaces, underscores, or non-ASCII characters), then reboot and retry the install.
You're installing a driver, a Windows feature, or an optional component, and setup bails out with SPAPI_E_INVALID_MACHINENAME. The error code is 0X800F0220. Windows is telling you the machine name doesn't conform to Universal Naming Convention (UNC) rules. UNC is the naming format used for network paths like \\SERVER\Share. For local machine names, the rules are stricter than most people assume: up to 15 characters, letters A-Z, digits 0-9, and hyphens. No spaces. No underscores. No accents. No emoji. No trailing hyphens either.
The real-world trigger I see most often is a name change made on a whim. Someone renames their laptop to "Mike's PC 🚀" or "DEV_BOX_01" a few months back, everything seems fine on the surface, and then a driver installer or a DISM feature install refuses to complete because the setup API validates the machine name against UNC rules before it writes anything. It also shows up on OEM images where the original name was set to a string with a space, and on machines joined to a workgroup with a name that was legal in an older Windows version but isn't accepted by current setup components.
You can confirm the current name and its format before you touch anything. Open an elevated Command Prompt and run:
hostname
wmic computersystem get name
Both should return the same string. If it has a space, an underscore, a period, an apostrophe, or anything outside A-Z, 0-9, and hyphen, that's your culprit. Don't guess — check first.
Fix 1: Rename the PC with Settings
- Open Settings > System > About.
- Click Rename this PC (Windows 11) or Rename this PC (advanced) then Rename this PC (Windows 10).
- Type a new name using only letters, numbers, and hyphens. Keep it under 15 characters. Example:
DESKTOP-A7K2orLAPTOP-JDOE. Skip the apostrophe. Skip the space. - Click Next, then Restart now.
- After the reboot, sign back in. You should see the new name in Settings > System > About.
- Retry the driver or feature install that failed. It should proceed past the point where it stopped before.
If you're on a domain and someone else manages the machine account, coordinate with them. Renaming a domain-joined PC drops its trust relationship until the object is updated. In a small shop, just rejoin or use netdom.
Fix 2: Rename with Command Line
For lab machines, VMs, or scripted builds, use this instead. Open an elevated Command Prompt:
wmic computersystem where name="%computername%" call rename name="DESKTOP-A7K2"
shutdown /r /t 0
The rename command returns ReturnValue = 0; on success. Anything else is a failure — usually because the name has a bad character or you're not running elevated. The reboot is mandatory. Windows won't apply the new name to all subsystems until it restarts.
On a domain, use netdom instead so the machine account object updates in one shot:
netdom renamecomputer %COMPUTERNAME% /newname:DESKTOP-A7K2 /userd:DOMAIN\admin /passwordd:* /force
shutdown /r /t 0
Fix 3: Change the name in the registry (last resort)
Only do this when Settings and the command line both refuse, which happens on locked-down or broken images. Open regedit as admin and navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
Edit ComputerName and ActiveComputerName. Use only A-Z, 0-9, hyphen. Close regedit. Reboot. Registry edits don't trigger the same validation path, so this can get you unstuck when the GUI is throwing the same error back at you.
Heads up: some environments have a group policy that blocks renames. If Settings shows the rename option greyed out, check gpedit.msc under Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options, and look for any rename policy. If it's set, you need to lift it before any of the above will work.
Alternative fixes if the name isn't the problem
- Check the hostname in the offline image. If you're servicing a WIM or VHD, the machine name inside the image may be bad even if the running OS is fine. Mount it and check
HKLM\SYSTEM\...\ComputerNameinside the offline hive. - Look at the setupapi.dev.log. It lives in
C:\Windows\INF\setupapi.dev.log. Search for0X800F0220and read the surrounding lines. The driver or component that triggered the failure is named a few lines above. - Run the installer from a local path. UNC paths and mapped drives can produce confusing errors that look like this one. Copy the driver package to
C:\Tempand run it from there. - Reset the network stack if you literally see a \\ path error. The error text mentions UNC, which occasionally means the network path failed, not the machine name. Run
netsh int ip resetandipconfig /flushdns, then reboot.
Prevention
Pick a machine name pattern before you build the machine and stick to it. My rule in every shop I've run: uppercase letters, digits, and one hyphen, max 12 characters. WKS-042, LT-SMITH, VM-BUILD01. No apostrophes for "Personal" names. No underscores. No emoji. No spaces. If you're deploying at scale, set the pattern in your imaging script so nobody gets creative after the fact. A two-minute rename right now saves you a two-hour debugging session the next time a driver pack or feature install decides to validate the machine name.