Obtain the MAC address, cpu serial number, and motherboard serial number through windows command wmic

Source: Internet
Author: User
: This article describes how to obtain the MAC address, cpu serial number, and motherboard serial number through the windows system command wmic in PHP. if you are interested in the PHP Tutorial, refer to it. PHP obtains the MAC address, cpu serial number, and motherboard serial number through the windows system command wmic. the source code is as follows: class HardwareInfo {// obtains the MAC address function getMacAddress () {$ return_arry = array (); @ exec ("wmic nicconfig get macaddress", $ return_arry); $ mac_addr = $ return_arry [1]; $ mac_addr = str_replace (":", "", $ mac_addr ); // remove the character ":" return $ mac_addr;} // Obtain the CPU serial number function getCpuSN () {$ return_arry = array (); @ exec ("wmic cpu get processorid", $ return_arry); $ cpu_sn = $ return_arry [1]; return $ cpu_sn;} // Obtain the motherboard serial number function getBaseboardSN () {$ return_arry = array (); @ exec ("wmic baseboard get serialnumber", $ return_arry); $ baseboard_sn = $ return_arry [1]; $ baseboard_sn = str_replace ("-", "", $ baseboard_sn); // remove the character "-" return $ baseboard_sn;} from the string. example: Include'Hardwareinfo. php '; $ hw_addr = new HardwareInfo (); $ mac_addr = $ hw_addr-> getMacAddress (); $ cpu_sn = $ hw_addr-> getCpuSN (); $ baseboard_sn = $ hw_addr-> getBaseboardSN (); echo 'Mac address :'. $ mac_addr.'
'; Echo 'CPU Serial Number:'. $ cpu_sn .'
'; Echo' motherboard address: '. $ baseboard_sn .'
'; Supplement: The use of wmic commands can be referred to: http://blog.csdn.net/hnllc2012/article/details/48733383

The above describes how to obtain the MAC address, cpu serial number, and motherboard serial number through the windows system command wmic in PHP, including some content, and hope to help those who are interested in the PHP Tutorial.

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.