Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get local computer name instead of server name!

Status
Not open for further replies.

SNosko

Technical User
Jul 3, 2002
73
0
0
US
I need to get the local computer name and add it to a box but when I run this code I get the server name. How can I get the local computer name instead?

SNosko

_________________


Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.management
Imports System.Web
Imports System.Net
Imports System.Environment

________________

Public Sub New()
objOS = New ManagementObjectSearcher("Select * From Win32_OperatingSystem")
For Each objMgmt In objOS.Get
m_strComputerName = objMgmt("csname").ToString()
Next
End Sub

Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerName
End Get
End Property
_______________


Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
varComNM = ComputerName()
Me.txtComNM.Text = varComNM
End Sub

 
i think its a security issue, although it would be nice to work on a local network.

so, no you cant via web server pages, as far as ive found out.
 
You could do it by using an activex component but that would limit you to IE only (and the users would have to allow it).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I get the computer name with this:

Dim host As System.Net.IPHostEntry
host = System.Net.Dns.GetHostByAddress(Context.Request.ServerVariables.Item("REMOTE_HOST"))
dim machineName as string = host.HostName
 
Yes that may work but only if you are using the relevant authentication method otherwise that will just be blank.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
mmaz,

That worked great. Thanks! Do you know how to use this computer name to get the Computer serial number?

SNosko
 
The serial number of what? The hard drive, the motherboard etc...

Whichever one you say though, I suspect only an activex component would have priviliges to find it and even that may be a long shot.




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Sorry, the serial number of the local computer system. It would be the BIOS serial number.

SNosko
 
Thank you mmaz but that code (Q21617669) returns the Server's serial number in ASP.NET and not the local clients. It looks like it will work in VB.NET's Windows Forms but not ASP.NET's Web Forms.

SNosko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top