Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
strComputer = "." objWMIService = GetObject(StrCat("winmgmts:!\\" , strComputer , "\root\cimv2")) colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True AND DHCPEnabled = True") ForEach objAdapter In colAdapters Message( "Physical address: " , objAdapter.MACAddress ) Message( "IP address: " , objAdapter.IPAddress(0) ) Next
Option 2 - Using IPCONFIG:
;*************************************************************************** ;**Gets IP And MAC Information From Current Network Card (nic) ;*************************************************************************** #DefineFunction GetTCPIPInfo_UDF(value) address = "" origdir = DirGet() OutputFile = StrCat (origdir, "IPCFG_TEMP.TXT") If WinVersion(4) == 4;WINNT RunHideWait(Environment('COMSPEC'), '/c IPCONFIG /ALL >"%OutputFile%"') Else RunHideWait('WINIPCFG', '/ALL /BATCH > "%OutputFile%"') EndIf If !FileExist(OutputFile) MessageTxt = StrCat ("TCP/IP parameters can't be determined.", @CRLF) MessageTxt = StrCat (MessageTxt, @CRLF, "No data will be captured.", @CRLF) Message (Caption, MessageTxt) Exit EndIf fs = FileSize (OutputFile) buf = BinaryAlloc(fs) BinaryRead(buf, OutputFile) ; ; Grab value from file ; lacptr = BinaryIndexEx(buf, 0, "Description", @FWDSCAN, 0) ; Run( OutputFile, "" ) ;Used for debugging ptr = BinaryIndexEx(buf, lacptr, value, @FWDSCAN, 0) ; only query if value exists If ptr != -1 colonptr = BinaryIndexEx(buf, ptr, ":", @FWDSCAN, 0) CRLFptr = BinaryIndexEx(buf, ptr, @CRLF, @FWDSCAN, 0) Address = BinaryPeekStr(buf, colonptr+2, CRLFptr-colonptr-2) Address = StrTrim(Address) EndIf BinaryFree (buf) FileDelete(OutputFile) Return Address #EndFunction dataitem = "Physical Address" result = GetTCPIPInfo_UDF(dataitem) Pause(dataitem,result) dataitem = "IPv4 Address" result = GetTCPIPInfo_UDF(dataitem) Pause(dataitem,result)
Article ID: W16226
File Created: 2012:03:15:14:17:22
Last Updated: 2012:03:15:14:17:22