Total_newbie Posted March 16, 2007 Share Posted March 16, 2007 Hi, I have created a basic GUI(master.au3) which contains a button that calls a specific function from a Include file(slave.au3). The problem is that the execution of the command netstat -a >> netstat-a.log hangs, apparently doesn't run properly and also does not return control to the GUI. I made a test where I call the same function from the included script using one main script and it works perfectly. I think I'm missing something regarding the GUI piece. Can somebody help me? Thanks Below are the two codes that I'm using. expandcollapse popup;scriptname=master.au3 Opt("GUIOnEventMode", 1) #include <slave.au3> #include <GUIConstants.au3> $mainwindow = GUICreate("Livelab Tool", 300, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseClicked") GUISetState(@SW_SHOW,$mainwindow) $button = GUICtrlCreateButton("Run", 20, 70, 80) While 1 Sleep(1000) ; Idle around WEnd GUICtrlSetOnEvent($button, "_MainSlave") Func _CloseClicked() Exit EndFunc ;scriptname: slave.au3 #include <Constants.au3>; Required for $STDERR_CHILD use Func _RunCommand($command,$tool) ConsoleWrite(" [i] Starting " & $tool & @CRLF) $ourproc = Run(@ComSpec & " /c " & $command, "", @SW_HIDE,$STDERR_CHILD) While 1 $line = StderrRead($ourproc) If @error Then ExitLoop ConsoleWrite(" [X] WARNING: " & $line) Wend EndFunc Func _MainSlave() Consolewrite("This is the _MainSlave function") ;Running NETSTAT $command = "netstat -a >> netstat-a.log" $tool="NETSTAT" _RunCommand($command,$tool) EndFunc Link to comment Share on other sites More sharing options...
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