Take the 2-minute tour ×

I need to get the host name currently running the application. Any idea?

share|improve this question
Why have you yags vb.net when the title says c#. –  Ash Burlaczenko Aug 16 '10 at 16:01
C# or VB.NET ... Any would be accepted –  Beginner_Pal Aug 16 '10 at 16:28

5 Answers 5

up vote 33 down vote accepted

Something to bear in mind is that System.Environment.MachineName; and System.Windows.Forms.SystemInformation.ComputerName; will give you the NETBIOS name of the machine (restricted to 15 characters).

If you want the full TCP/IP based host name you can use Dns.GetHostName():

string hostName = System.Net.Dns.GetHostName();

Or you can use:


Which will return the full computer name set during installation.

share|improve this answer
Well, the docs are a bit vague on how it's implemented, but it is implied that it requires a) a working network connection, b) a round-trip to the DNS server, and c) that the DNS actually knows your machine name (it doesn't have to, unless your a server) –  James Curran Aug 16 '10 at 16:09
@James Curran - Absolutely. But Environment.MachineName restricts the computer name to a 15 character NETBIOS name. GetHostName will retrieve the full TCP/IP based hostname. –  GenericTypeTea Aug 16 '10 at 16:21

Unless I am mistaken on what you want to do..

share|improve this answer
share|improve this answer

The My namespace contains many great "helper" functions like:

share|improve this answer
This appears to be limited to VB.NET and is proprietary to that language: msdn.microsoft.com/en-us/vstudio/ms789188.aspx –  Dan Esparza Sep 7 '12 at 17:37

To get fully qualified name, use:

share|improve this answer

Your Answer


