Yes, Windows user names can contain spaces
Posted by jpluimers on 2024/10/02
I forgot what triggered me querying for [Wayback/Archive] can windows user names contain spaces – Google Search.
Boy I was surprised that the answer is yes.
Following that I was totally not surprised that:
- a lot of software fails (often even during installation) when your Windows username contains one or more spaces
- even if you manage to change your username to not contain any spaces any more software still fails
The first is caused because hardly every one uses spaces in usernames. The second because software stores way too much information during installation then re-using it when running. If as software you need to keep a reference to a user, then use the SID of that user as that ID will never change.
You can get the SID of the current user using whoami /user or through various API calls, for instance on one of my machines:
C:\Users\jeroenp>whoami /user USER INFORMATION ---------------- User Name SID ======================= ============================================ desktop-4jjbh0k\jeroenp S-1-5-21-1522018678-69878723-2804176864-1002
So: do not ever put spaces in user names. Ever.
References:
- [Wayback/Archive] login – What are some compelling reasons to disallow spaces in usernames? – User Experience Stack Exchange
- [Wayback/Archive] Help! I put a space in my Windows User Name. Now What? | by Natalie Olivo | codeburst
- [Wayback/Archive] I had to rename my username because it had a space in it, causing – Microsoft Community
- [Wayback/Archive] Security identifiers (Windows 10) – Windows security | Microsoft Docs
- [Wayback/Archive] How to see all the user accounts that exist on your Windows PC or device | Digital Citizen (with solutions using
net user, PowerShell or interactively). - [Wayback/Archive] How To: Match a user profile to folders in HKEY_USERS (with solutions browsing registry keys and values)
–jeroen






Leave a comment