views:

1676

answers:

7

possibly using javascript or asp.net?

A: 

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.

Shoban
A: 

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.

aleemb
+4  A: 

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

Kelsey
+1  A: 

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.

nevets1219
+3  A: 

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.

Mark Robinson
I ran that code with 192.168.1.100 (ip address of machine hosting browser) and it gave an error: 'Error:The requested name is valid, but no data of the requested type was found'
shogun
192.168.*.* is a private ip address, you'll need to run the code on a computer on the private network and have a DNS server on the network for this to work.
Mark Robinson
A: 

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();
    }
WACM161
Yeah this is great if you want info about the server!!!
Josh Stodola
+1  A: 

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

Sean Molam