JS obtains the MAC address and IP address of the computer.

Source: Internet
Author: User

// The ActiveX plug-ins in the system are used to obtain IP addresses and physical addresses.

<Object ID = locator classid = CLSID: 76a64158-cb41-11d1-8b02-00600806d9b6 viewastext> </Object>

<Object ID = Foo classid = CLSID: 75718c9a-f029-11d1-a1ac-00c04fb6c223> </Object>

<Script language = JScript event = onobjectready (objobject, objasynccontext) for = Foo>

If (objobject. ipenabled! = NULL & objobject. ipenabled! = "Undefined" & objobject. ipenabled = true)

{
If (objobject. macaddress! = NULL & objobject. macaddress! = "Undefined ")

Macaddr = objobject. macaddress;
If (objobject. ipenabled & objobject. IPaddress (0 )! = NULL & objobject. IPaddress (0 )! = "Undefined ")

Ipaddr = objobject. IPaddress (0 );
If (objobject. dnshostname! = NULL & objobject. dnshostname! = "Undefined ")

Sdnsname = objobject. dnshostname;

}
</SCRIPT>
<Script language = JScript>
VaR service = locator. connectserver ();
VaR macaddr;
VaR ipaddr;
VaR domainaddr;
VaR sdnsname;
Service. Security _. impersonationlevel = 3;
Service. instancesofasync (Foo, 'win32 _ networkadapterconfiguration ');

</SCRIPT> <script language = JScript event = "oncompleted (hresult, perrorobject, pasynccontext)" for = Foo>

Alert ("physical address" + macaddr + "ip address" + ipaddr + "Host Name" + sdnsname ))
</SCRIPT>"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.