2017-05-22 3 views
0
나는 컴퓨터 이름을 표시 간단한 스크립트를 만들려고 해요

을 나열, 사용자 이름, IP 주소 및 이더넷 인터페이스 (유선) 이름을 기록하며 MAC의 :VBS 스크립트 인터페이스와 MAC

intCount = 0 
strMAC = "" 
' We're interested in MAC addresses of physical adapters only 
strQuery = "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID > ''" 

Set objWMIService = GetObject("winmgmts://./root/CIMV2") 
Set colItems  = objWMIService.ExecQuery(strQuery, "WQL", 48) 

For Each objItem In colItems 
If objItem.AdapterType = "Ethernet 802.3" then 
If InStr(strMAC, objItem.MACAddress) = 0 Then 
    strMAC = strMAC & ", " & objItem.MACAddress 
    Name = objItem.Name & vbCRLF 
    intCount = intCount + 1 
End If 
End If 
Next 

' Remove leading comma 
If intCount > 0 Then strMAC = Mid(strMAC, 2) 
dim NIC1, Nic, StrIP, CompName 
Set NIC1 = 
GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") 
For Each Nic in NIC1 
if Nic.IPEnabled then 
StrIP = Nic.IPAddress(i) 
Set WshNetwork = WScript.CreateObject("WScript.Network") 
Dim objNetwork 
Set objNetwork = CreateObject("WScript.Network") 
CompName = WshNetwork.Computername 
Dim WMI, Configs, Config, Adapters, Adapter 
Set WMI = GetObject("winmgmts:{impersonationlevel=impersonate}root/cimv2") 

strUserName = wshNetwork.UserName 

MsgBox "IP Adres: "&StrIP & vbNewLine _ 
& "Computer Name: "&CompName & vbNewLine _ 
& "Login: "&strUserName & vbNewLine _ 
& "Interface and MAC: "& Name, & strMAC ,4160,"Information about IP" 

wscript.quit 
end if 
next 

하지만 그건 아무도 도와 줄 수 없습니까?

답변

0

변경

Set NIC1 = 
GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") 

라인

Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") 

하나에 여기에, 제거 :

& "Interface and MAC: "& Name, & strMAC ,4160,"Information about IP" 

==>

& "Interface and MAC: "& Name & strMAC ,4160,"Information about IP"