Search the Community
Showing results for tags 'read txt file'.
-
Hi first step i write ipconfig output to ipconfig.txt. Now i try to find all Adapters and get for each adapter: Adapter Name, Description, Media State and Mac Adress and put it to listbox. I search for "Ethernet Adapter" but they are other entrys like Wireless Adapter .. How can i get all Adapters from ipconfig.txt and information for each adapter Adapter Name, Description, Media State and Mac Adress and write to listbox ? Would appreciate any help! #include <File.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 451, 328, 856, 237) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25) $List1 = GUICtrlCreateList("", 88, 8, 353, 305) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select ;Case $GUI_EVENT_CLOSE Case $msg = $GUI_EVENT_CLOSE Exitloop Case $msg = $Button1 $FilePath= "C:\temp\IPconfig.txt" $StringToSearch= "Ethernet adapter" $CaseSense=0 $Lines=_FileCountLines($FilePath) $hFile=FileOpen($FilePath,0) $Lines=_FileCountLines($FilePath) For $i=0 To Number($Lines) $Test=FileReadLine($hFile,$i) If StringInStr($Test,$StringToSearch,$CaseSense) Then $filereadAdapter = FileReadLine($hFile,$i) $filereadDescription = FileReadLine($hFile,$i+4) $filereadMediaState = FileReadLine($hFile,$i+2) $filereadMAcAdress = FileReadLine($hFile,$i+5) GUICtrlSetData($List1 , "Adapter: " & $filereadAdapter & @CRLF& "Description: "& $filereadDescription & @CRLF & "Media State: " & $filereadMediaState & @CRLF & "Mac Adress: " & $filereadMAcAdress& @CRLF) ;ExitLoop EndIf Next FileClose($hFile)