VBS获取本机IP地址

 '获取本机IP
'
owner DeViL
'return 本机的IP地址
Public Function GetIP
   ComputerName
="."
    
Dim objWMIService,colItems,objItem,objAddress
    
Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
    
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    
For Each objItem in colItems
        
For Each objAddress in objItem.IPAddress
            
If objAddress <> "" then
                GetIP 
= objAddress
                
Exit Function
            
End If
        
Next
    
Next
End Function

评论

此博客中的热门博文

选Ruby还是选Python?

[转贴]江西潘阳陈振翊报警被警方击毙事件始末

轻松的事,多半是错的事