' Kod konfiguruje dla okrelonego poczenia adres IP, mask podsieci i domyln bram
' ------ KONFIGURACJA SKRYPTU ------
strComputer = "."
strConnection = "Poczenie lokalne"
strIP = Array("1.22.2.2")
strMask = Array("255.255.255.0")
strGatewayIP = Array("1.2.3.3")
' ------ KONIEC KONFIGURACJI ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colNA = objWMI.ExecQuery("select * " & _
                            " from Win32_NetworkAdapter " & _
                            " where NetConnectionID = '" & strConnection & "'" ) 
for each objNA in colNA
   set colNAConfig = objWMI.ExecQuery _
      ("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & _
        objNA.DeviceID & "'} " & _
      " WHERE resultClass = win32_NetworkAdapterConfiguration ")
   for each objNAConfig in colNAConfig
      intRC = objNAConfig.EnableStatic(strIP,strMask)
      intRC2 = objNAConfig.SetGateways(strGatewayIP)
      if intRC = 0 and intRC2 = 0 then
         WScript.Echo "Adres IP skonfigurowano dla " & strConnection
      elseif intRC = 1 or intRC2 = 1 then
         WScript.Echo "Konieczne jest przeadowanie systemu, aby dokonane zmiany uwzgldniono dla " & _
                      strConnection
      else
         WScript.Echo "Wystpi bd podczas konfigurowania adresu IP dla " & _
                      strconnection & ": " & intRC & " i " & intRC2
      end if
   next
next
