The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

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:

  1. a lot of software fails (often even during installation) when your Windows username contains one or more spaces
  2. 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:

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.