rootx Posted July 29, 2020 Share Posted July 29, 2020 (edited) expandcollapse popup;----------- here it works!!! $net = Run(@ComSpec & " /c netstat -an",'',@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Return_Output($net) ;--------------------------------------------------------------- $xcopy = Run(@ComSpec & " /c xcopy c:\mytest d:\mytest2 /Y /H /E /C",'',@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Return_Output($xcopy) Func Return_Output($job) Dim $_StderrRead='', $_StdoutRead='', $_StdReadAll='' While ProcessExists ( $job ) $_StderrRead = StderrRead ( $job ) If @error Then ExitLoop If Not @error And $_StderrRead <> '' Then ConsoleWrite ( "STDERR read : " & $_StderrRead & @CRLF ) $_StdReadAll = $_StdReadAll & $_StderrRead & @CRLF EndIf $_StdoutRead = StdoutRead ( $job ) If Not @error And $_StdoutRead <> '' Then ConsoleWrite ( "STDOUT read : " & $_StdoutRead & @CRLF ) $_StdReadAll = $_StdReadAll & $_StdoutRead & @CRLF EndIf Wend ProcessClose($job) Return ($_StdReadAll) EndFunc I would like to read the output of xcopy, can anyone tell me what i am wrong with in my script, thanks!! SO windows 10 64 Edited July 31, 2020 by rootx Link to comment Share on other sites More sharing options...
rootx Posted July 29, 2020 Author Share Posted July 29, 2020 this is really not applicable !! The solution is to run the script with Admin permissions (#RequireAdmin)!!! Is there any way to make it work without it? Link to comment Share on other sites More sharing options...
TheSaint Posted July 29, 2020 Share Posted July 29, 2020 (edited) @error only really works for the command immediately preceding it, so the following isn't going to work well. $_StderrRead = StderrRead ( $job ) If @error Then ExitLoop If Not @error And $_StderrRead <> '' Then How it should be written is as follows. $_StderrRead = StderrRead ( $job ) If @error Then ExitLoop ElseIf $_StderrRead <> '' Then If it is an error then by definition it isn't NOT an error, so will exit the loop and never get to that statement. Haven't run your code, so not sure if that alone fixes things. Edited July 29, 2020 by TheSaint rootx 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Nine Posted July 29, 2020 Share Posted July 29, 2020 This is working for me without #RequireAdmin : #include <Constants.au3> $net = Run(@ComSpec & " /c netstat -an",'',@SW_HIDE,$STDERR_MERGED) ConsoleWrite (Return_Output($net) & @CRLF) ;--------------------------------------------------------------- $xcopy = Run(@ComSpec & ' /C xcopy c:\Apps\Temp\*.* c:\Apps\Temp2 /Y /H /E /C /I','',@SW_HIDE, $STDERR_MERGED+$STDIN_CHILD) ConsoleWrite (Return_Output($xcopy) & @CRLF) Func Return_Output($job) ProcessWaitClose ($job) Return StdoutRead ($job) EndFunc By the way, your Return_Output is unnecessary too complex. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rootx Posted July 29, 2020 Author Share Posted July 29, 2020 I want to parse the output during execution and not at the end. Link to comment Share on other sites More sharing options...
rootx Posted July 29, 2020 Author Share Posted July 29, 2020 Yes, I'm getting to old!!!! thank you Link to comment Share on other sites More sharing options...
TheDcoder Posted July 29, 2020 Share Posted July 29, 2020 4 hours ago, TheSaint said: @error only really works for the command immediately preceding it, so the following isn't going to work well. Some clarification: I think @error is only reset after calling another function, not after every command (statement). So the first code example should also work in theory, however I do agree that it is bad style to use @error like that. seadoggie01 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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