# 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?

For good reasons the organisations stops users from downloading/running apps, so oneClick deploy and downloading batch files is out of the question with the existing infrastructure/policy setup.

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

Answers

Via email

Send them a link for:

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
add comment

## 7 Answers

Send them a link for:

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
"c:\program files\internet explorer\iexplore.exe" c:\users\%username%\Desktop\computername.html

-
add comment

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
add comment

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
%>

-
add comment

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

-
add comment

This should work as client-side VBScript:

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


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.

-
add comment

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.

-
add comment

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.

-
add comment