Monday, July 28, 2008

Reading MAC Address From a Text File

Hey, Scripting Guy! How Can I Read the MAC Address From a Text File?
regex pattern:
objReg.Pattern = "((?:(\d{1,2}|[a-fA-F]{1,2}){2})(?::|-*)){6}"




Set objFS = CreateObject("Scripting.FileSystemObject")
Set objRegExp = new RegExp
objRegExp.Pattern = "((?:(\d{1,2}|[a-fA-F]{1,2}){2})(?::|-*)){6}"
Set objFile = objFS.OpenTextFile("C:\logs\logfile.txt")
strFileContents = objFile.ReadAll
arrLines = Split(strFileContents,vbNewLine)

For Each strLine in arrLines
Set colMatches = objRegExp.Execute(strLine)
For Each strMatch in colMatches
WScript.Echo strMatch
Next
Next

No comments: