We had a major storm through here recently and we suffered damage to the house roof and ceilings. I just received the quote to repair. I’m hoping that a small fraction of the 80,000 odd people that download SDIO and/or Desktop Info every month won’t mind chipping in a few dollars to help out. Click on the big blue button at the bottom of the page to help us keep a roof over our heads, literally!
Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.
Good day to you,
I'm currently evaluating Desktop Info and in the process of trying to replicate our current BGInfo information, I have noticed that the documentation for HOST does not seem to reflect what actually ends up in the return values.
According to the docs, it's
%1 the NetBIOS name of the local computer
%2 dns domain name
%3 fully qualified dns domain and host name
%4 dns host name
%5 NetBIOS name
%6 physical dns domain name
%7 physical fully qualified domain and host name
%8 physical dns host name
%9 physical NetBIOS name
%upn% The user principal name (for example, someone@example.com).
The implication is that this aligns with
- GetComputerNameW
- GetComputerNameExW("ComputerNameDnsDomain")
- GetComputerNameExW("ComputerNameDnsFullyQualified")
- GetComputerNameExW("ComputerNameDnsHostname")
- GetComputerNameExW("ComputerNameNetBIOS")
- GetComputerNameExW("ComputerNamePhysicalDnsDomain")
- GetComputerNameExW("ComputerNamePhysicalDnsFullyQualified")
- GetComputerNameExW("ComputerNamePhysicalDnsHostname")
- GetComputerNameExW("ComputerNamePhysicalNetBIOS")
However, in practice, what I get when I query HOST is
- NetBIOS-Name
- NetBIOS-Name
- DNS-Hostname
- DNS-Domain
- FQDN
- NetBIOS-Name
- DNS-Hostname
- DNS-Domain
- FQDN
This is true both when having one HOST-item with all return values in display as well as when having one HOST-item per return value.
I happen to be able to distinguish NetBIOS- and DNS-hostname, because this machine has a hostname that is longer than the 15 characters Windows allows for NetBIOS, so I am certain when it comes to which is which.
I cannot distinguish between virtual and physical (ComputerNameDnsDomain vs. ComputerNamePhysicalDnsDomain) because this is a physical machine.
I have checked the actual output of GetComputerNameExW on this computer and it is as expected. So it's not a problem of the API returning false values.
The environment is Windows 11 Pro 24H2 10.0.26100 / 26100.4652.
It would be great if you could check whether there is an issue in the Desktop Info code or if this is an issue with my setup.
I would think that somebody else would've noticed before if it were broken, but on the other hand, everyone might just be using it to get the hostname and not notice that everything beyond %1 is jumbled.
On a related sidenote, %upn% is empty in both HOST and USER, despite the fact that this is a domain-joined machine.
The user account does have an actual userPrincipalName and the USERDOMAIN, USERDOMAIN_ROAMINGPROFILE and USERDNSDOMAIN environment variables are set, but %upn% shows nothing, while %1 does show the proper naked username.
Maybe there's a relation?
Thank you for your extensive work!
Here's where the code gets the data:
1. NetBIOS Name GetComputerNameW 2. ComputerNameNetBIOS GetComputerNameEx 3. ComputerNameDnsHostname GetComputerNameEx 4. ComputerNameDnsDomain GetComputerNameEx 5. ComputerNameDnsFullyQualified GetComputerNameEx 6. ComputerNamePhysicalNetBIOS GetComputerNameEx 7. ComputerNamePhysicalDnsHostname GetComputerNameEx 8. ComputerNamePhysicalDnsDomain GetComputerNameEx 9. ComputerNamePhysicalDnsFullyQualified GetComputerNameEx 10. NameUserPrincipal GetComputerObjectName
This seems to match up with your findings and yes, the docs don't seem to match the output. I'm guessing at some point I rearranged the output and neglected to update the docs.
upn comes from the GetComputerObjectNameW function in Secur32.dll with the NameUserPrincipal parameter. I notice there's room for improvement in that code which I'll have a look at.
Thank you for the feedback!
Then I'll take %5 under the assumption that the value will remain the same and the docs will be changed. 🙂
That seems reasonable.Thank you for the feedback!
Then I'll take %5 under the assumption that the value will remain the same and the docs will be changed. 🙂
When I get the next update out you get to test the upn for me.
