How can I read the client's machine/computer name from the browser?

MetaGuru picture MetaGuru · May 28, 2009 · Viewed 289.9k times · Source

How can I read the client's machine/computer name from the browser?
Is it possible using JavaScript and/or ASP.NET?

Answer

Kelsey picture Kelsey · May 28, 2009

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