Using ASP to obtain the MAC address information of server network card--Application technique

Source: Internet
Author: User
'----------------------extract information for all network adapters--------------------'

Public Function Getmacinfo ()
On Error Resume Next

Dim FSO, Filestr, Aspsleepthread, Cmdstr, Sysdir, WshShell, Cmdre, Macfilecontentfile, macfilecontent
Const macfile = "TMPYESOULSOFT001.LLP"
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")

Sysdir = Split (Globalmod.getsysdir, ",") (1)
If InStr (LCase (Sysdir), "system32") = 0 Then
Getmacinfo = "This system can only run in NT, Windows 2000, Windows.NET, Windows Xp, Windows 2003 and other 32-bit systems, do not support the following 32-bit system!" "
Exit Function
Else
Cmdstr = Sysdir + "\cmd.exe/c" + Sysdir + "\ipconfig.exe/all >" + Server.MapPath (MacFile)
End If
Cmdre = Shell (Cmdstr, vbhide)
If cmdre <> 0 Then
Set macfilecontentfile = fso. OpenTextFile (Server.MapPath (MacFile), 1, False, Tristateusedefault)
' Getmacinfo = Macfilecontentfile.readall ()
' Response.Flush
Filestr = Macfilecontentfile.readall ()
Macfilecontentfile.close
Set Macfilecontentfile = Nothing
Set Aspsleepthread = Server.CreateObject ("Yesoulsoft.sleepthread")
' Define the time that the thread hangs, here is the millisecond
Aspsleepthread.sleeptime = 500
Aspsleepthread.beginsleepthread
Getmacinfo = Executeone (Filestr, "Physical address. ........:(.*)")
Set Aspsleepthread = Nothing
Else
Getmacinfo = "The system is currently unable to obtain your network information, please check the permission inheritance relationship before running this system!" "
Exit Function
End If
Delfile MacFile

Set FSO = Nothing

End Function
'------------------match one result-------------------' string
Public Function Executeone (INPSTR, PATSTR)
Dim oRe, Omatch, omatches
Set oRe = New RegExp
Ore.pattern = Patstr
Inpstr = LCase (INPSTR)
Ore.ignorecase = True
Set omatches = Ore.execute (INPSTR)
Set omatch = omatches (0)
Executeone = omatch.submatches (0)
End Function
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.