FIN

 Code:
Break on
; Declare variables to prevent scope creep
Dim $InFile, $OutFile, $Offline			; file names for input and output
Dim $remotepc					; computer name, from input file
Dim $Rc						; return-code catcher
Dim $Version					; Version data from Computer

$Rc = SetOption('NoVarsInStings', 'On')

$OutFile = ('c:\test\DHCP\DHCPorStatic.txt')
$InFile  = ('c:\test\DHCP\computerlist.txt')
$Offline = ('c:\test\DHCP\Offline.txt')

; Open the input file - no strings in quotes!
If Open( 1 , $InFile) <> 0
  'Failed to open ' $InFile ' - aborting!' ?
  Exit 1
EndIf

; same for the output file
If Open( 2 , $OutFile, 5) <> 0
  'Failed to open ' $OutFile ' - aborting!' ?
  Exit 1
EndIf

$Rc = WriteLine(2, 'Remotepc' + ',' + 'ConnectionName' + ',' + 'AdapterName' + ',' + 'Mac Address' + ',' + 'Static Address' + ',' + 'DHCP Enabled' + ',' + 'IPaddress/SM' + ',' + @CRLF)

; same for the offline file
If Open( 3 , $Offline, 5) <> 0
  'Failed to open ' $Offline ' - aborting!' ?
  Exit 1
EndIf

; Read the first line, then loop until EOD (End Of Data) error
$remotepc = ReadLine(1)
While Not @ERROR

'Computer: ' $remotepc ?	; display the current computer

  ; Only Communicate with the computer if it is online
  If Ping($remotepc, 0) <>0

for each $nc in Enumnetworkconnections(3,$remotepc) 
    $ConnectionName=split($nc,",")[0] 
    $MACAddress=split($nc,",")[1] 
    $AdapterName=split($nc,",")[2] 

if instr($ConnectionName,"1394") or instr($ConnectionName,"bluetooth")
      ;skipit
else

$Rc = WriteLine(2, $remotepc + ',' + $connectionname + ',' + $AdapterName + ',' + getipoptions("MACAddress",$remotepc,$macaddress) + ',' + getipoptions("StaticIP",$remotepc,$macaddress) + ',' + getipoptions("DHCPEnabled",$remotepc,$macaddress) + ',' + getipoptions("IPAddress",$remotepc,$macaddress) + ',' + @CRLF)

endif

next

Else

$Rc = WriteLine(3, $remotepc + @CRLF)

Endif  
  $remotepc = ReadLine(1)

Loop

$Rc = Close(1)
$Rc = Close(2)

;;====================================================================== 
;; 
;;FUNCTION       ping() 
;; 
;;ACTION         ping - Pings a host 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION	 2.0 - 2007/10/20 - WHS version 
;;		 1.0 - based on KORG Ping UDF by Jochen Polster, enhanced to  
;;			return values and IP's 
;; 
;;SYNTAX         ping(host, [Flag], [Wait]) 
;; 
;;PARAMETERS     host - name of host to ping 
;;               FLAG - if negative, returns IP Address 
;;                      if >0, specifies number of tries (default is 1) 
;;               Wait - optional ping timeout value 
;;                
;; 
;;REMARKS        ERROR is set to 0 if success, 1 otherwise. 
;; 
;;RETURNS        FLAG >= 0: returns 1 if host is reachable, 0 if not 
;;               FLAG <  0: Returns IP address if resolvable, 0.0.0.0 if not 
;; 
;;DEPENDENCIES   OS Commands Ping & Find 
;; 
;;TESTED WITH    NT4, W2K, WXP 
;; 
;;EXAMPLES       Ping('hostname')       ; returns Success/Failure 
;;               Ping('hostname',-1)    ; returns IP Address 
; 
Function Ping($_Host, OPTIONAL $_Flag, OPTIONAL $_Wait)
 
  Dim $_oExec				; WSH Object 
  Dim $_Tries				; # of times to ping 
  Dim $_Timeout				; Ping timeout value 
  Dim $_Response			; Response Flag 
  Dim $_Line				; Line returned from command string 
  Dim $_Cmd				; first part of command string 
  Dim $_Count				; current ping count 
 
  $_Flag    = Val($_Flag)		; determine what to do 
  $_Wait    = Val($_Wait)		;  
  $_Tries   = 1				; one ping 
  $_Timeout = 1000			; 1 second timeout 
 
  ; set timeout if Wait is non-zero 
  If $_Wait > 0
    $_Timeout = $_Wait
  EndIf
 
  If $_FLAG > 0        ; Multiple pings - return on first reply 
    $_Tries = $_FLAG
  EndIf
 
  ; Ping the host $_Tries times, but only until a response is received 
  $_Count = 0
 
  ; search for reply from host during PING 
  $_Cmd = '%COMSPEC% /c ping.exe -4 -n 1 -w ' + $_Timeout + ' ' + $_Host 
  If $_Flag < 0
    $_Cmd = $_Cmd + ' | %SystemRoot%\System32\Find "Pinging"'
  Else
    $_Cmd = $_Cmd + ' | %SystemRoot%\System32\Find "Reply" | %SystemRoot%\System32\Find "TTL="'
  EndIf
  Do
    $_oExec = CreateObject("WScript.Shell").Exec($_Cmd)
    If Not VarType($_oExec)=9 $Ping = 'WScript.Shell Exec Unsupported' Exit 10 EndIf
    $_Line = Split(Join(Split($_oExec.StdOut.ReadAll + $_oExec.StdErr.ReadAll,CHR(13)),''),CHR(10))[0]
    $_Response = IIf($_Line, 1, 0)
    If $_Response
      $_Count = $_Tries
    EndIf
    $_Count = $_Count + 1
    If $_Count <  $_Tries Sleep 0.25 EndIf
  Until $_Count >= $_Tries
 
  ; If FLAG >= 0, return success/failure - otherwise return IP address 
  If $_FLAG >= 0
    $Ping = $_Response
  Else
    If Not $_Response
      $Ping = '0.0.0.0'
    Else
      ; In this mode we return the IP address - we should have the HOSTNAME 
      ; handle the 'duh' factor for times when we get the IP address instead! 
      If InStr($_Line,'[') > 0
        $Ping= Split(Join(Split($_Line,']',-1),'['), '[')[1]
      Else
        $Ping = Split(Split($_Line,' ',-1)[1], ':')[0]
      EndIf
    EndIf
  EndIf
 
  Exit Not $_Response       ; set the error code 
 
EndFunction

;Function:  
; GetIPOptions()  
;  
;Author:  
; Allen Powell  
;  
;Version:  
; 1.0 2006/03/15
;  
;Action:  
; Display/Get IP Settings   
; 
;Syntax:  
; GetIPOptions($Setting,optional $remotepc, optional $macaddress) 
;  
;Parameters:  
; $setting - Any valid property from Win32_NetworkAdapterConfiguration class, See examples below and 
;             ;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapterconfiguration.asp 
; $remotepc - (Optional) Remote Computer Name 
; $macaddress - (Optional)  In Computers with more than Network Adapter, provide the MACAddress to target it settings 
; 
;Returns: 
; String containing setting 
; 
;Dependencies 
;  WMI with Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later 
;  Tested with Kixtart 4.52 Beta 
; 
;Notes 
;  If a computer has more than one Network Adapter and the macaddress is not provided it will return the last adapter's 
;  information 
; 
;Example1:  
; 
;? "        Mac Address:  " + getipoptions("Macaddress") 
;? "     Static Address:  " + getipoptions("StaticIP") 
;? "       DHCP Enabled:  " + getipoptions("DHCPEnabled") 
;? "       IPaddress/SM:  " + getipoptions("IPAddress") 
;? "      IPaddress0/SM:  " + getipoptions("IPAddress0") 
;? "      IPaddress1/SM:  " + getipoptions("IPAddress1") 
;? "      IPaddress2/SM:  " + getipoptions("IPAddress2") 
;? "      IPaddress3/SM:  " + getipoptions("IPAddress3") 
;? "          DefaultGW:  " + getipoptions("DefaultGW") 
;? "        DNS Servers:  " + getipoptions("DNSServers") 
;? "       WINS Servers:  " + getipoptions("WINSServers") 
;? "          DNSSuffix:  " + getipoptions("DNSDomain") 
;? "   DNS Search Order:  " + getipoptions("DNSDomainSuffixSearchOrder") 
;? "        DHCP Server:  " + getipoptions("DHCPServer") 
;? "DHCP Lease Obtained:  " + getipoptions("DHCPLeaseObtained") 
;? " DHCP Lease Expires:  " + getipoptions("DHCPLeaseExpires") 
; 
;Example2:  List settings for Remote Computers including those with more than one Network Adapter. 
; Requires EnumNetworkConnections() - http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=138769&an=0&page=0#138769
; 
;break on 
;$remotepc="computername" 
;for each $nc in Enumnetworkconnections(3,$remotepc) 
;    $ConnectionName=split($nc,",")[0] 
;    $MACAddress=split($nc,",")[1] 
;    $AdapterName=split($nc,",")[2] 
;    ? "    Connection Name:  " + $connectionname 
;    ? "         MACAddress:  " + $MACAddress 
;    ? "       Adapter Name:  " + $AdapterName 
;    ? "        Mac Address:  " + getipoptions("Macaddress",$remotepc,$macaddress) 
;    ? "     Static Address:  " + getipoptions("StaticIP",$remotepc,$macaddress) 
;    ? "       DHCP Enabled:  " + getipoptions("DHCPEnabled",$remotepc,$macaddress) 
;    ? "       IPaddress/SM:  " + getipoptions("IPAddress",$remotepc,$macaddress) 
;    ? "      IPaddress0/SM:  " + getipoptions("IPAddress0",$remotepc,$macaddress) 
;    ? "      IPaddress1/SM:  " + getipoptions("IPAddress1",$remotepc,$macaddress) 
;    ? "      IPaddress2/SM:  " + getipoptions("IPAddress2",$remotepc,$macaddress) 
;    ? "      IPaddress3/SM:  " + getipoptions("IPAddress3",$remotepc,$macaddress) 
;    ? "          DefaultGW:  " + getipoptions("DefaultGW",$remotepc,$macaddress) 
;    ? "        DNS Servers:  " + getipoptions("DNSServers",$remotepc,$macaddress) 
;    ? "       WINS Servers:  " + getipoptions("WINSServers",$remotepc,$macaddress) 
;    ? "          DNSSuffix:  " + getipoptions("DNSDomain",$remotepc,$macaddress) 
;    ? "   DNS Search Order:  " + getipoptions("DNSDomainSuffixSearchOrder",$remotepc,$macaddress) 
;    ? "        DHCP Server:  " + getipoptions("DHCPServer",$remotepc,$macaddress) 
;    ? "DHCP Lease Obtained:  " + getipoptions("DHCPLeaseObtained",$remotepc,$macaddress) 
;    ? " DHCP Lease Expires:  " + getipoptions("DHCPLeaseExpires",$remotepc,$macaddress) 
;    ? "---------------" 
;next 
; 
;
 
function GetIPOptions($Setting,optional $remotepc, optional $macaddress)
  dim $objWMIService, $colitems, $objnetadapter,$targetadapter,$,$allnics,$counter,$Mask,$SN, $IP, $IPAddress,$toggle
  if $remotepc=""
    $remotepc="."
  endif
  if $macaddress=""
    $allnics=1
  endif
  $objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
  if @error
    exit @error
  endif
  $colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1")
  For Each $objNetAdapter In $colItems
    if $macaddress=$objNetAdapter.macaddress or $allnics
      select
        case instr($setting,"IPAddress")>0
          if right($setting,1)="s" or val(right($setting,1))>3 or len($setting)>10
            $targetadapter=0
          else
            $targetadapter=right($setting,1)
          endif
          $counter=0
          for each $IP in $objNetAdapter.IPAddress
            if "" + $counter=$targetadapter
              $IPAddress=$IP
            endif
            $counter=$counter+1
          next
          $counter=0
          for each $SN in $objNetAdapter.IPSubnet
            if "" + $counter=$targetadapter
              $Mask=$SN
            endif
            $counter=$counter+1
          next
          $GetIPOptions=$IPAddress
          if $mask
            $GetIPOptions=$GetIPOptions + "," + $Mask
          endif  
        case $setting="WINSServers"
          $GetIPOptions=$objNetAdapter.WINSPrimaryServer
          if $objNetAdapter.WINSSecondaryServer<>"" 
            $GetIPOptions=$GetIPOptions + "," + $objNetAdapter.WINSSecondaryServer
          endif
        case 1
          select
            case $setting="DefaultGW" or $setting="DefaultGateway" or $setting="Gateway"
              $setting="DefaultIPGateway"
            case $setting="DNSServers"
              $setting="DNSServerSearchOrder"
            case $setting="StaticIP" or $setting="Static"
              $setting="DHCPEnabled"
              $toggle=1
          endselect
          $=execute("$" + "GetIPOptions=" + "$" + "objNetAdapter." + $setting)
          select 
            case vartype($GetIPOptions)>=8192 ;array 
              $GetIPOptions=join($GetIPOptions,",")
            case vartype($GetIPOptions)=11    ;boolean 
              if $GetIPOptions=0 - $toggle
                $GetIPOptions="False"
              else
                $GetIPOptions="True"
              endif
          endselect
      endselect
    endif
  Next
endfunction

;Function:  
; EnumNetworkConnections()  
;  
;Author:  
; Allen Powell  
;  
;Version:  
; 2.0 2006/03/15 Complete Re-write (backward compatible) 
; 1.0 2005/05/11 Original Version - Returned just the "Connection Name" 
;  
;Action:  
; Enumerates/Lists the Network Connections names  
; 
;Syntax:  
; EnumNetworkConnections(optional $mode, optional $remotepc)  
;  
;Parameters:  
; $mode - (Optional) Numeric expression that is the sum of values below 
;       - 0 Connection Name (default) 
;       - 1 MACAddress 
;       - 2 Network Adapter Name 
; 
; $remotepc - (Optional) Remote Computer Name 
; 
;Returns: 
; Array of Network Connection Names, optionally with MACAddress and/or Name of the Network Card 
; 
;Dependencies 
;  WMI with Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later 
;  Tested with Kixtart 4.52 Beta 
;Example:  
; 
;for each $nc in Enumnetworkconnections() 
;  ? $NC 
;next 
; 
function EnumNetworkConnections(optional $mode,optional $remotepc)
  dim $NCs[0],$objWMIService,$colItems,$objItem,$counter
  if $remotepc=""
    $remotepc="."
  endif
  $objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
  if @error
    exit @error
  endif
  $colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where (MACAddress is not null) and (NetConnectionID is not null)")
  For each $objItem in $colItems
    redim preserve $NCs[$counter]
    $NCs[$counter]=$objItem.NetConnectionID
    if $mode & 1
      $NCs[$counter]=$NCs[$counter] + "," + $objItem.MACAddress
    endif
    if $mode & 2
      $NCs[$counter]=$NCs[$counter] + "," + $objItem.Name
    endif    
    $counter=$counter + 1
  Next
  $EnumNetworkConnections=$NCs
endfunction
_________________________
Where ever you go, there you are.