-1

I need to get my desktop information using Javascript it may be windows, MAC, Linux os. I need to get System Unique Id, OS name etc, for example in a mobile device we can get device Id, in the same way, there is any possibility to get the Unique Id for the desktop?

achu
  • 639
  • 2
  • 10
  • 26
  • Possible duplicate of [How can I read the client's machine/computer name from the browser?](https://stackoverflow.com/questions/922476/how-can-i-read-the-clients-machine-computer-name-from-the-browser) – Unsenzrd Feb 18 '19 at 12:29

3 Answers3

1

JavaScript doesn't have access to that. Closer you can do is navigator.userAgent.

console.log(navigator.userAgent);

What you could do is ask a service that can read that sort of information using an XMLHttpRequest

nick zoum
  • 7,216
  • 7
  • 36
  • 80
0

var parser = new UAParser();
      
window.navigator.userAgent
console.log(parser.getResult());

// let's test a custom user-agent string as an example
var uastring = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu / 11.10 Chromium / 15.0 .874 .106 Chrome / 15.0 .874 .106 Safari / 535.2 ";
parser.setUA(uastring);

var result = parser.getResult();
// this will also produce the same result (without instantiation):
// var result = UAParser(uastring);

console.log(result.browser); // {name: "Chromium", version: "15.0.874.106" }
console.log(result.device); // {model: undefined, type: undefined, vendor: undefined }
console.log(result.os); // {name: "Ubuntu", version: "11.10"}
console.log(result.os.version); // "11.10"
console.log(result.engine.name); // "WebKit"
console.log(result.cpu.architecture); // "amd64"

// do some other tests
var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
console.log(parser.setUA(uastring2).getBrowser().name); // "Konqueror"
console.log(parser.getOS()); // {name: "OpenBSD", version: undefined}
console.log(parser.getEngine()); // {name: "KHTML", version: "4.1.4"}

var uastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US)AppleWebKit / 534.11(KHTML, like Gecko) Version / 7.1 .0 .7 Safari / 534.11 ';
console.log(parser.setUA(uastring3).getDevice().model); // "PlayBook"
console.log(parser.getOS()) // {name: "RIM Tablet OS ", version: "1.0.0"}
console.log(parser.getBrowser().name); // "Safari"
<!doctype html>
<html>

<head>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ua-parser-js@0.7.19/src/ua-parser.min.js"></script>
</head>

<body>
</body>

</html>
nick zoum
  • 7,216
  • 7
  • 36
  • 80
  • Here's the full code to do it. i hope this is what you need. –  Feb 18 '19 at 12:36
  • @AdarshaJha Edited your answer, so that users can test it. – nick zoum Feb 18 '19 at 12:49
  • @nickzoum thank you so much. i appreciate your help. –  Feb 18 '19 at 13:13
  • @achu You can use the fingerprintJS library, it helps a lot with calculating a browser fingerprint. By the way, on Panopticlick you can see how unique this usually is. –  Feb 18 '19 at 13:16
0

We can access OS name using Java Script . you can access this link .

http://www.javascripter.net/faq/operatin.htm