hemichallenger Posted August 19, 2014 Posted August 19, 2014 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #RequireAdmin Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $mainWindow = GUICreate ("TEST MAC and IP", 329, 100, 330, 442) GUISetBkColor(0xE3E3E3) GUISetFont(9, 300) $Button1 = GUICtrlCreateButton("TEST", 99.5, 50, 130, 21) $Input1 = GUICtrlCreateInput('', 64.5, 12, 200, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) StringUpper(GUICtrlRead($Input1)) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, "Computer Name or IP") GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW, $mainWindow) While 1 $gMsg = GUIGetMsg() Switch $gMsg Case $GUI_EVENT_CLOSE Exit; Case $Button1 Dim $strComputer = GUICtrlRead ($Input1) If $strComputer = "" Then MsgBox(16,"ERROR","No Entry", 10) Else _TEST() EndIf EndSwitch WEnd Func _TEST() Local $strComputer = GUICtrlRead ($Input1) $ping = Ping($strComputer, 500) If $ping Then $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\CIMV2') If Not @error Then $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE (IPEnabled = True AND NOT Caption LIKE '%VMware%' AND NOT Caption LIKE '%VirtualBox%')") For $objAdapter In $colItems If $objAdapter.MACAddress <> "" Then MsgBox(0, "Info", "Computer Name: " & $strComputer & @CRLF & _ "MAC Address: "& $objAdapter.MacAddress & @CRLF & _ "IP Address: "& $objAdapter.IPAddress(0)) EndIf Next EndIf Else MsgBox(64, "test", "Computer could not be contacted.") EndIf EndFunc Func MyErrFunc() Local $HexNumber If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) MsgBox(64, "test", "Intercepted a COM ""Component Object Model"" Error with the computer!" & @CRLF & @CRLF & _ "Description : " & $oMyError.windescription, 10) SetError($HexNumber) EndIf Return EndFunc Got a small issue that i ran into out on the field. Maybe someone might know how cancel the request if it take to long to get. This is a simple script just to grab the MAC and IP address. The issue I ran into is when the remote computer is busy running a scan. and when I run the script on that computer it take so long to grab the info the script locks up until the computer send the info. Is there a way if the information is not gathered in 20 seconds to cancel or timeout the request.
Jfish Posted August 19, 2014 Posted August 19, 2014 Perhaps you could check the object variable value with AdLibRegister every 20 seconds and if it is null do something ...? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now