1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Vbscript to grab ip addresses from a text file

Discussion in 'Web Design, HTML And CSS' started by Cleptography, Sep 6, 2010.

  1. Cleptography

    Cleptography New Member

    Joined:
    Sep 2, 2010
    Messages:
    39
    Likes Received:
    7
    Trophy Points:
    0
    This one here is a vbscript that grabs all the ips from a text file. Modifiy the file name section to point to the file you are using. I use this one mostly for parsing wireshark output.

    Vbscript to grab ip addresses from a text file
    ----------------------------------------------------
    Code:
    Const ForReading = 1
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("Your File Name Here.txt", ForReading)
    
    strSearchString = objFile.ReadAll
    
    objFile.Close
    
    Set objRegEx = CreateObject("VBScript.RegExp")
    
    objRegEx.Global = True   
    objRegEx.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
    
    Set colMatches = objRegEx.Execute(strSearchString)  
    
    If colMatches.Count > 0 Then
        For Each strMatch in colMatches   
           Wscript.Echo strMatch.Value
        Next
    End If
     

Share This Page