'关键代码来自网络
' ----- ExeScript Options Begin -----
' ScriptType: window
' DestDirectory: temp
' Icon: default
' OutputFile:
' ----- ExeScript Options End -----
option explicit
dim strComputer
dim strResult
dim objWMIService
dim IPConfigSet
dim IPConfig
dim strAddress
dim colComputers
dim objComputer
dim strMac
strComputer = "."
strResult = "IP: "
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For Each strAddress in IPConfig.IPAddress
strResult = strResult & strAddress & " "
Next
End If
Next
strResult = strResult & vbCrLf & "主机名为 "
strComputer = "."
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
strResult = strResult & objComputer.Name & vbCrLf
Next
set colComputers = objWMIService.ExecQuery("Select MACAddress from Win32_NetworkAdapterConfiguration")
strResult = strResult & vbCrlf & "MAC地址 " & vbCrlf
for each IPConfig in colComputers
if not IsNull(IPConfig.MACAddress) then
strResult = strResult & IPConfig.MACAddress & vbCrlf
end if
next
Wscript.Echo strResult