# A way to find the (Windows) computer name via the browser?

Ideally I'd like to send a link via staff email that staff could click on to reveal their computer name. (Specifically first part of the 'Long computer name' found in the second tab of My Computer Properties.)

Is there some JavaScript/VBScript/ActiveX object on the client side, or CGI script on the server-side that can let a user know their computer name by returning a simple web page?

Oh - it should work for the enterprise wide install of Internet Explorer 6/Windows XP that isn't likely to be updated anytime soon.

Via email

http://%computername%


This will bring up "Internet explorer cannot display the webpage" but the address bar will show the machine name.

Server Side

You want the REMOTE_HOST server variable. First enable reverse DNS on the web server. Then create a page to return the variable you want. Here it is in ASP.

<% Response.Write ServerVariables("REMOTE_HOST") %>

-
Commenting as this does not involve using the broswer. This SF question has a novel way of displaying %COMPUTERNAME% instead of My Computer. Works on Windows XP also. –  jscott Aug 17 '10 at 16:41

http://%computername%


This will bring up "Internet explorer cannot display the webpage" but the address bar will show the machine name.

or

They could run a bat file from their desktop:

echo %computername% >> c:\users\%username%\Desktop\computername.html

-

If this is Windows Only environment, your best bet will be OneClick deployment and simple c# (or vb.net) program which uses System.Environment.MachineName with or without combination with System.Net.Dns.GetHostByAddress for more information.

-

This should work as client-side VBScript:

Set ADSysInfo = CreateObject ("ADSystemInfo")
Set CurrentComp = GetObject ("LDAP://" & ADSysInfo.ComputerName)


This implementation just gets the short name, without your domain appended; look in ADSIEdit or on TechNet or MSDN to get the full list of properites you can retrieve.

You might also need to do some jiggery-pokery in your intranet zone IE settings.

-

You want the REMOTE_HOST server variable. First enable reverse DNS on the web server. Then create a page to return the variable you want. Here it is in ASP.

<% Response.Write ServerVariables("REMOTE_HOST") %>


If you want to take a look at all the possible variables, use this

<%
for each x in Request.ServerVariables
response.write(x  & ": " & Request.ServerVariables(x) & "<br />")
next
%>

-

This doesn't answer your question, but you might consider deploying Sysinternals BGInfo as part of your desktop image. This puts the name of the PC (and other relevant information you specify) right on the user's desktop background.

-
+1 good tip but not possible in this case. –  Stephen Jun 19 '09 at 20:57

Not really, no, the browser security is pretty much setup to prevent web servers from getting information like that.

I guess since you mention CGI is an option, if DNS updates where working perfectly, you might be able to write some kind of program that runs on an internal web server that looks up the reverse DNS record for the IP address that was used to connect and then returns that.

I suppose, you could store an HTA on a file server and send a UNC to the users.

-

Or client could open commandprompt and type "hostname" and hit enter. Or Start > Run > (Winkey+R) type: "cmd.exe /k hostname" and hit enter.

-