0

Example:

<script type = "text/JavaScript">
try
{
var ax = new ActiveXObject("WScript.Network");
document.write('User: ' + ax.UserName + '<br />');
document.write('Computer: ' + ax.ComputerName + '<br />');
}
catch (e)
{
document.write('Permission to access computer name is denied' + '<br />');
}
</Script>

Actually I am Getting the Following output:

Permission to access computer name is denied

Please help to get Client Machine Computer name using jquery / Javascript (Php).

patricksweeney
  • 3,939
  • 7
  • 41
  • 54
Dinesh G
  • 1,325
  • 4
  • 17
  • 24

3 Answers3

3

The problem is explained in the following Link. They say it is (in most cases) impossible to do.

However, if you are making an internal application you can 'register' each computer to a database and save the computername and IP. And then you can later use the IP of the host to determine the hostname by querying it to the database.

Community
  • 1
  • 1
Perrykipkerrie
  • 380
  • 1
  • 3
  • 12
  • is this possible to change any settings in each system to access computer name...... – Dinesh G Dec 17 '15 at 06:52
  • Its will only work on older IE. Add your domian to the Tools -> Internet Options -> Security tab -> Trusted sites Zone -> Sites. ref [link](https://bytes.com/topic/javascript/answers/92507-get-computer-name) – Perrykipkerrie Dec 17 '15 at 06:58
2

ActiveX is a Microsoft-proprietary framework.Your code works only in IE. In other browsers ActiveXObject really does not exist. You will get an error like this,

Uncaught ReferenceError: ActiveXObject is not defined

Mûhámmàd Yäsår K
  • 1,492
  • 11
  • 24
1
  var network = new ActiveXObject('WScript.Network');
        // Show a pop up if it works
        alert(network.computerName);
Om R Kattimani
  • 105
  • 1
  • 9