vbs獲取當前主機IP


Function GetIP

    GetIP = ""
    
    Dim objWMIService, colAdapters, objAdapter
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colAdapters = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    If colAdapters.Count = 0 Then
        Exit Function
    End If
    If Ubound(colAdapters.ItemIndex(0).IPAddress) = 0 Then
        Exit Function
    End If

    GetIP = colAdapters.ItemIndex(0).IPAddress(0)

End Function

ip = GetIP()

If Not ip = "" Then
    
End If


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM