Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the computer name [duplicate]

I want to get the current computer name.

this is my code:

Public Function GetComputerName() As String
    Dim ComputerName As String
    ComputerName = System.Net.Dns.GetHostName
    Return ComputerName
End Function

this code working, but i remember that there is faster way.

what is the fast way to get the computer name?

like image 798
Nh123 Avatar asked Nov 14 '12 22:11

Nh123


People also ask

Can you duplicate a computer name in Active Directory?

Duplicate Machine NamesAD Bridge supports duplicate computer names by generating a new hashed computer name during the join process for subsequent conflicting computer names. The generated name will consist of the first seven characters from the original name, a hyphen, and then a unique seven digit code.

How do I find duplicate network names?

Use nbtstat -n in a command window to see which name is in the Conflict state. (eventvwr: Another machine has sent a name release message to this machine probably because a duplicate name has been detected on the TCP network. The IP address of the node that sent the message is in the data.

How do I find the original name of my computer?

Click on the Start button. Right-click on Computer. Select Properties. Under Computer name, domain, and workgroup settings you will find the computer name listed.


2 Answers

you can just use without function:

System.Net.Dns.GetHostName 

or:

Environment.MachineName 
like image 139
famf Avatar answered Sep 23 '22 14:09

famf


This is not that good the previous anwser,but if you love to work with forms:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    Me.Text = System.Windows.Forms.SystemInformation.ComputerName

End Sub

System.Windows.Forms.SystemInformation gives a lot of nice informations.

-> UserDomainName

-> UserName

like image 28
Check-Kay Wong Avatar answered Sep 21 '22 14:09

Check-Kay Wong