Milas Posted February 5, 2016 Share Posted February 5, 2016 (edited) Hello, Im trying to capture information from a dos command using StdoutRead() and have it appear in an edit box in my GUI. For some reason when i run the command with a msgbox in the while loop it will transfer the data to the edit box properly. but when i eliminate the msg box from the while loop nothing appears in the edit box. I cant sem to figure out exactly where i am going wrong here. Sample code: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <inet.au3> #include <Constants.au3> #RequireAdmin #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 449, -815, 111) $User = GUICtrlCreateButton("Who's Logged On", 16, 16, 171, 33) $Host = GUICtrlCreateButton("Get Hostname", 16, 64, 171, 33) $Mac = GUICtrlCreateButton("Get MAC Address", 16, 112, 171, 33) $sUser = GUICtrlCreateInput("", 216, 24, 217, 21) $sHost = GUICtrlCreateInput("", 216, 72, 217, 21) $sMac = GUICtrlCreateInput("", 216, 120, 217, 21) $pInfo = GUICtrlCreateInput("", 448, 168, 169, 21) $Label1 = GUICtrlCreateLabel("Version", 448, 150, 164, 19) $Acc = GUICtrlCreateButton("User Account", 456, 16, 155, 41) $IP = GUICtrlCreateInput("IP/Host Name", 8, 408, 193, 21) $Version = GUICtrlCreateButton("Check Version", 16, 160, 171, 33) $pName = GUICtrlCreateInput("Enter Program", 216, 168, 217, 21) $Ping = GUICtrlCreateButton("Ping", 232, 392, 169, 41) $mDrive = GUICtrlCreateButton("Remote C$", 432, 392, 163, 41) $nPrinter = GUICtrlCreateButton("Mapped Printers", 16, 208, 171, 33) $pList = GUICtrlCreateEdit("", 216, 208, 217, 73) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $User remote_user() case $Host remote_host() case $Mac remote_Mac() Case $Version remote_program() case $ping ping_customer() case $mDrive map_drive() case $nPrinter get_printers() Case $acc Account() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd func remote_user() $pid= Run(@ComSpec & " /c wmic /node:214.47.41.200 computersystem get username", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($pid) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) ;<----- this msgbox i would like to get rid off but code doesnt seem to wrk without it guictrlsetdata($pList, $line) Wend While 1 $line = StderrRead($pid) If @error Then ExitLoop guictrlsetdata($pList, $line) Wend EndFunc thank you to all that help or reply Edited February 5, 2016 by Milas wanted to edit the code Link to comment Share on other sites More sharing options...
Milas Posted February 5, 2016 Author Share Posted February 5, 2016 alright while no one seems to have respond thank you for anyone who tried and just did not reply. Now im not sure if its the most correct answer but i added a sleep command for one second in between the run function and the while loop. i guess the wmic process needs time to resolve. hopefully i can find a better answer to this dilemma. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2016 Moderators Share Posted February 5, 2016 Milas, Please remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. M23 Milas 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Milas Posted February 5, 2016 Author Share Posted February 5, 2016 my apologizes i didn't mean to come across that way. i will have better diction in the future Link to comment Share on other sites More sharing options...
Developers Jos Posted February 5, 2016 Developers Share Posted February 5, 2016 Try: Func remote_user() $pid = Run(@ComSpec & " /c wmic computersystem get username", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line &= StdoutRead($pid) If @error Then ExitLoop GUICtrlSetData($pList, $line) WEnd While 1 $line &= StderrRead($pid) If @error Then ExitLoop GUICtrlSetData($pList, $line) WEnd EndFunc ;==>remote_user Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Milas Posted February 5, 2016 Author Share Posted February 5, 2016 jos Thank you VERY MUCH! i am new to autoit and im not familiar with &= 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