среда, 6 марта 2013 г.

Имя PC, ip, шлюза и DNS


'15/02/2013 ITVolna
'Скрипт выводит имя ПК, ip, шлюза и DNS

set WshShell = CreateObject("WScript.Shell")
set WshNet = WScript.CreateObject("WScript.Network")
Set objNetwork = CreateObject("WScript.Network")
'Получаем имя ПК
strComputer = objNetwork.ComputerName
'MsgBox strComputer

'Получаем Сетевые настройки
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig In IPConfigSet
'Ip-адрес
  For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
      strIP = strIP & "  " & IPConfig.IPAddress(i)
  Next
'Шлюз по умолчанию
  For i=LBound(IPConfig.DefaultIPGateway) to UBound(IPConfig.DefaultIPGateway)
      strIPGateway = strGateway & "  " & IPConfig.DefaultIPGateway(i)
  Next
'MAC адрес
   strDNS = strMACAddress & "  " & IPConfig.MACAddress(i)
  For i=LBound(IPConfig.DNSServerSearchOrder) to UBound(IPConfig.DNSServerSearchOrder)
      strDNS = strDNS & "  " & IPConfig.DNSServerSearchOrder(i)
  Next
Next

MsgBox  strComputer & strMACAddress & strDNS & strIPGateway & strIP

Комментариев нет:

Отправить комментарий