'获取电脑名称
MsgBox CreateObject("Wscript.Network").computername
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetIPMAC(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
GetIPMAC = objAddress & ",MAC:" & objItem.MACAddress
Exit For
End If
Next
Exit For
Next
End Function
Str = CreateObject("Wscript.Network").ComputerName
'获取本地电脑用户名
MsgBox Str
'获取本地电脑IP和MAC地址
MsgBox GetIPMAC(Str)