STATUS_INVALID_COMPUTER_NAME (0XC0000122) Fix
This error means Windows can't parse the remote computer name you typed. Fix it by correcting the name format or checking your hosts file.
You're trying to connect to a remote computer — maybe through Remote Desktop, a mapped drive, or a network share — and Windows throws up STATUS_INVALID_COMPUTER_NAME (0XC0000122). That's frustrating, especially when you're sure you typed everything right. Let's fix it.
The Quick Fix: Check Your Computer Name Syntax
The most common cause is a typo in the remote computer name. Windows expects a valid NetBIOS name (15 characters or fewer, no special characters except hyphens) or a fully qualified domain name (FQDN). Here's what to check:
- Look for extra spaces or quotes. If you copied the name from an email or a document, sometimes hidden characters slip in. Type it manually:
\\SERVER01for a network path, orSERVER01.example.comfor an FQDN. - NetBIOS names can't have underscores or special symbols. If your computer name is
MY_WORKSTATION, that's invalid. Rename it or use the IP address instead. - Try the IP address. If you're using a name, swap it with the remote computer's IP (like
\\192.168.1.50). If that works, the name itself is the problem.
After you fix the name, try connecting again. You should see the remote resource appear immediately.
Why This Error Happens
Windows validates computer names against a set of rules defined in the NetBIOS specification. The error 0XC0000122 means the name string failed that validation — it's not a network timeout or a permission issue. The remote computer might be perfectly online, but the name you gave doesn't match any valid format.
Specifically, the check happens at the SMB layer (for file sharing) or the RDP layer (for remote desktop). If the name has illegal characters — like spaces, underscores, or a trailing backslash — Windows rejects it before it even tries to resolve it. This is by design: it prevents ambiguous or malicious names from causing problems later.
Less Common Variations That Trigger This Error
1. Corrupted Hosts File
If you have a manually edited hosts file in C:\Windows\System32\drivers\etc\hosts, a malformed entry can cause this. For example, a line like 192.168.1.50 MY PC (with a space in the name) will fail. Open the hosts file in Notepad as Administrator, look for any lines with spaces or special characters in the computer name column, and fix them. After saving, flush DNS by running ipconfig /flushdns in Command Prompt. Then try your connection again.
2. DNS Alias with Invalid Characters
If you're using a CNAME or an A record that has an illegal NetBIOS character (like an underscore in my_pc.example.com), Windows will still reject it. Use a hyphen or remove the character. Run nslookup my_pc.example.com to see what the DNS server returns — if the alias has an underscore, that's your culprit.
3. Mapped Drive Using a Bad Name
When mapping a network drive with net use or through File Explorer, a typo in the UNC path triggers the same error. For instance, net use Z: \\SERVER-NAME\share is fine, but net use Z: \\SERVER NAME\share (with a space) will fail. Double-check the path in your batch script or the dialog box.
4. Remote Desktop Connection with a Misnamed Gateway
If you're using RD Gateway, the gateway server name might have an invalid character. Go to the RDP file settings, look at the Gateway server field, and ensure it's a valid NetBIOS name. I've seen this happen when someone pastes the gateway name from a SharePoint link that includes a trailing space.
How to Prevent This Error Going Forward
The easiest prevention is to always use IP addresses or FQDNs when you're connecting to remote computers. FQDNs like server01.company.local are less picky about special characters (though underscores are still a no-no). Also, avoid naming local machines with underscores or spaces — Windows 10 and 11 allow it during setup, but it's a bad idea. Rename them immediately if you see this error.
Finally, if you manage multiple computers, standardize your naming scheme: use only letters, numbers, and hyphens. That way, you'll never hit 0XC0000122 again due to syntax issues.
Was this solution helpful?