Organizational Research By

Surprising Reserch Topic

how can i read the clients machine computer name from the browser


how can i read the clients machine computer name from the browser  using -'javascript,asp.net,computer-name'

asked Sep 9, 2015 by rajesh
0 votes
5 views



Related Hot Questions

9 Answers

0 votes

You can do it with IE 'sometimes' as I have done this for an internal application on an intranet which is IE only. Try the following:

function GetComputerName()
{
    try
    {
        var network = new ActiveXObject('WScript.Network');
        // Show a pop up if it works
        alert(network.computerName);
    }
    catch (e) { }
}

It may or may not require some specific security setting setup in IE as well to allow the browser to access the ActiveX object.

Here is a link to some more info on WScript: More Information

answered Sep 9, 2015 by rajesh
0 votes

Well you could get the ip address using asp.net, then do a reverse DNS lookup on the ip to get the hostname.

From the ASP.NET Developer's cookbook ... Performing a Reverse-DNS Lookup.

answered Sep 9, 2015 by rajesh
0 votes

Browser, Operating System, Screen Colors, Screen Resolution, Flash version, and Java Support should all be detectable from JavaScript (and maybe a few more). However, computer name is not possible.

EDIT: Not possible across all browser at least.

answered Sep 9, 2015 by rajesh
0 votes

It is not possible to get the users computer name with Javascript. You can get all details about the browser and network. But not more than that.

Like some one answered in one of the previous question today.

I already did a favor of visiting your website, May be I will return or refer other friends.. I also told you where I am and what OS, Browser and screen resolution I use Why do you want to know the color of my underwear? ;-)

You cannot do it using asp.net as well.

answered Sep 9, 2015 by rajesh
0 votes

No this data is not exposed. The only data that is available is what is exposed through the HTTP request which might include their OS and other such information. But certainly not machine name.

answered Sep 9, 2015 by rajesh
0 votes

Try getting the client computer name in mozilla firfox by using the code given below.

netscape.security.PrivilegeManager.enablePrivilege( 'UniversalXPConnect' ); 

var dnsComp = Components.classes["@mozilla.org/network/dns-service;1"]; 
var dnsSvc = dnsComp.getService(Components.interfaces.nsIDNSService);
var compName = dnsSvc.myHostName;

Also the same piece of code can be put as an extension and it can called from your web page.

Please find the sample code below.

Extension code:

var myExtension = {
  myListener: function(evt) {

//netscape.security.PrivilegeManager.enablePrivilege( 'UniversalXPConnect' ); 
var dnsComp = Components.classes["@mozilla.org/network/dns-service;1"]; 
var dnsSvc = dnsComp.getService(Components.interfaces.nsIDNSService);
var compName = dnsSvc.myHostName;
content.document.getElementById("compname").value = compName ;    
  }
}
document.addEventListener("MyExtensionEvent", function(e) { myExtension.myListener(e); }, false, true); //this event will raised from the webpage

Webpage Code:












answered Sep 9, 2015 by rajesh
0 votes

Erm is there any reason why you can't just use the HttpRequest? This would be on the server side but you could pass it to the javascript if you needed to?

Page.Request.UserHostName

HttpRequest.UserHostName

The one problem with this is it would only really work in an Intranet environment otherwise it would just end up picking up the users Router or Proxy address...

answered Sep 9, 2015 by rajesh
0 votes

Page.Request.UserHostName is also “great if you want info about the server”

But why? The name implies that it returns what we want. And the ServerVariables equivalent is advertised on Microsoft sites as doing what we want, i.e., giving the host name of the remote. Yet both are giving me the IP address (not the name) of the host running IIS.

answered Sep 9, 2015 by rajesh
0 votes

We did something like this for an inhouse bugtracking tool, it got taken out before we went live but i think it would work I think a coop student found it on the internet somewhere :)

using System;
using System.Management;
using System.Windows.Forms;
namespace ComputerInfo

{
/// 
/// Summary description for Class1.
/// 
public class CPUInfo
{
    #region Properties
    private String osVersion;
    public String OSVersion
    {
        get { return this.osVersion; }
    }

    private String machineName;
    public String MachineName
    {
        get { return this.OSVersion; }
    }

    private int width;
    public int ScreenWidth
    {
        get { return this.width; }
    }

    private int height;
    public int ScreenHeight
    {
        get { return this.height; }
    }

    private String userName;
    public String UserName
    {
        get { return this.userName; }
    }

    private String clockSpeed;
    public String ClockSpeed
    {
        get { return this.clockSpeed; }
    }

    private String procName;
    public String ProcessorName
    {
        get { return this.procName; }
    }

    private String manufacturer;
    public String ProcessorManufacturer
    {
        get { return this.manufacturer; }
    }

    private String version;
    public String ProcessorVersion
    {
        get { return this.version; }
    }

    private double ram;
    public double RAM
    {
        get { return this.ram; }
    }

    private bool usehtml;
    public bool UseHTMLFormatting
    {
        get { return this.usehtml; }
        set { usehtml = value; }
    }
    #endregion

    public CPUInfo() : this(false)
    {

    }

    public CPUInfo(bool use_html_formatting)
    {
        usehtml = use_html_formatting;
        osVersion = System.Environment.OSVersion.ToString() ;
        machineName = System.Environment.MachineName.ToString();
        width = Screen.PrimaryScreen.Bounds.Width;
        height = Screen.PrimaryScreen.Bounds.Height;
        userName = "";
        clockSpeed = "";
        procName = "";
        manufacturer = "";
        version = "";
        ram = 0.0d;
        getMachineInfo();
    }

    private void getMachineInfo()
    {
        try
        {
            using(ManagementObjectSearcher win32Proc = new ManagementObjectSearcher("select * from Win32_Processor"),
                  win32CompSys = new ManagementObjectSearcher("select * from Win32_ComputerSystem"),
                  win32Memory = new ManagementObjectSearcher("select * from Win32_PhysicalMemory"))
            {
                foreach (ManagementObject obj in win32Proc.Get())
                {
                    clockSpeed = obj["CurrentClockSpeed"].ToString();
                    procName = obj["Name"].ToString();
                    manufacturer = obj["Manufacturer"].ToString();
                    version = obj["Version"].ToString();
                }
answered Sep 9, 2015 by rajesh

...