Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: List Active Network Adapters
Here is some code that retrieves a list of active network adapters using WMI (Windows Management Instrumentation). It retrieves the same list you see in the Device Manager under network adapters:
; Specify "" for local computer or a computer name (i.e. "COMPUTER01") ComputerName = "" User = "" Password = "" ; Get handle to WMI locator objLocator = ObjectCreate("WbemScripting.SWbemLocator") ; Connect to local or remote machine objService = objLocator.ConnectServer(ComputerName,"root/cimv2",User,Password) ; Set security level objSecurity = objService.Security_ objSecurity.ImpersonationLevel = 3 ; Execute WMI query on the WMI Win32_NetworkAdapterConfiguration class colAdapters = objService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True") ; Get handle to object collection hEnum = ObjectCollectionOpen(colAdapters) While 1 ; get adapter object handle objAdapter = ObjectCollectionNext(hEnum) ; Check if finished enumerating If objAdapter == 0 Then Break Message("Network Adapter", objAdapter.Description) ; Get IP address of adapter objIPAddress = objAdapter.IPAddress cnt = ArrInfo(objIPAddress, 1) For i = 0 To cnt-1 Message("IP address=",objAdapter.IPAddress(i)) Next ; Close object handle colAdapters = 0 EndWhile ; Close handle to object collection ObjectCollectionClose(hEnum) ; Explicitly close object handles objSecurity = 0 objService = 0 objLocator = 0 Exit
For more on WinBatch and WMI:
WMI Scripter: Tool to help users to generate and run scripts that use WMI. Tech Support Article ID: W16283
Article ID: W17501
File Created: 2014:07:18:09:11:48
Last Updated: 2014:07:18:09:11:48