HOST return values ...
 
Notifications
Clear all

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.

HOST return values do not align with documentation

4 Posts
2 Users
0 Reactions
1,203 Views
(@carlk)
New Member Registered
Joined: 4 months ago
Posts: 2
Topic starter  

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

  1. GetComputerNameW
  2. GetComputerNameExW("ComputerNameDnsDomain")
  3. GetComputerNameExW("ComputerNameDnsFullyQualified")
  4. GetComputerNameExW("ComputerNameDnsHostname")
  5. GetComputerNameExW("ComputerNameNetBIOS")
  6. GetComputerNameExW("ComputerNamePhysicalDnsDomain")
  7. GetComputerNameExW("ComputerNamePhysicalDnsFullyQualified")
  8. GetComputerNameExW("ComputerNamePhysicalDnsHostname")
  9. GetComputerNameExW("ComputerNamePhysicalNetBIOS")

However, in practice, what I get when I query HOST is

  1. NetBIOS-Name
  2. NetBIOS-Name
  3. DNS-Hostname
  4. DNS-Domain
  5. FQDN
  6. NetBIOS-Name
  7. DNS-Hostname
  8. DNS-Domain
  9. 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!


   
Quote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1778
 

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.


   
ReplyQuote
(@carlk)
New Member Registered
Joined: 4 months ago
Posts: 2
Topic starter  

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. 🙂 


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1778
 

Posted by: @carlk

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.

When I get the next update out you get to test the upn for me. 

 


   
ReplyQuote
Glenn's Page