BoskoBuha Posted August 5, 2009 Share Posted August 5, 2009 (edited) I'm trying to run robocopy from script's directory (yes, robocopy is in same directory as my script). Cptured PID is 0.:-( I tried to capture STDERR and STDOUT, but they are empty, while I know robocopy does produce output... #include <constants.au3> $RobocopyPID = RunWait(@ScriptDir&"\robocopy.exe", @ScriptDir, @SW_MAXIMIZE, $STDOUT_CHILD + $STDERR_CHILD) MsgBox(0, "PID", $RobocopyPID) While 1 $line = StdoutRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDOUT read ("&$RobocopyPID&"):", $line) Wend While 1 $line = StderrRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDERR read ("&$RobocopyPID&"):", $line) Wend I'm always open to AutoIt UDF alternative to robocopy though, but for now, I don't have time to implement one myself... Cheers, Bostjan Edit: Tried with Run still nothing in outputs..robocopy.exe Edited August 5, 2009 by BoskoBuha Link to comment Share on other sites More sharing options...
99ojo Posted August 5, 2009 Share Posted August 5, 2009 I'm trying to run robocopy from script's directory (yes, robocopy is in same directory as my script). Cptured PID is 0.:-( I tried to capture STDERR and STDOUT, but they are empty, while I know robocopy does produce output... #include <constants.au3> $RobocopyPID = RunWait(@ScriptDir&"\robocopy.exe", @ScriptDir, @SW_MAXIMIZE, $STDOUT_CHILD + $STDERR_CHILD) MsgBox(0, "PID", $RobocopyPID) While 1 $line = StdoutRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDOUT read ("&$RobocopyPID&"):", $line) Wend While 1 $line = StderrRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDERR read ("&$RobocopyPID&"):", $line) Wend I'm always open to AutoIt UDF alternative to robocopy though, but for now, I don't have time to implement one myself... Cheers, Bostjan Hi, just change your RunWait to Run. RunWait waits until the command is finished and then does the next lines in code. ;-)) Stefan Link to comment Share on other sites More sharing options...
BoskoBuha Posted August 5, 2009 Author Share Posted August 5, 2009 Hi,just change your RunWait to Run. RunWait waits until the command is finished and then does the next lines in code.That's what I wanted, to wait until it's done.....Nevertheless, still no results with Run.... Link to comment Share on other sites More sharing options...
99ojo Posted August 5, 2009 Share Posted August 5, 2009 That's what I wanted, to wait until it's done..... Nevertheless, still no results with Run.... Hi, 1st) If you wait until it's done, you can't read stdout anymore.So you have to use Run 2nd) This code gives me #include <constants.au3> $RobocopyPID = Run (@ScriptDir & "\robocopy.exe", @ScriptDir, @SW_MAXIMIZE, $STDOUT_CHILD + $STDERR_CHILD) MsgBox(0, "PID", $RobocopyPID) While 1 $line = StdoutRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDOUT read ("&$RobocopyPID&"):", $line) Wend While 1 $line = StderrRead($RobocopyPID) If @error Then ExitLoop MsgBox(0, "STDERR read ("&$RobocopyPID&"):", $line) Wend as result. ;-)) Stefan Link to comment Share on other sites More sharing options...
BoskoBuha Posted August 5, 2009 Author Share Posted August 5, 2009 (edited) Well, all I get is 0 for PID..... Now, I'm getting desperate enough to write my own _Robocopy UDF. ;-) But problem remains. Not just robocopy, ANYTHING I try to run with Run does not work.:-( Cheers, Bostjan Edited August 5, 2009 by BoskoBuha Link to comment Share on other sites More sharing options...
BoskoBuha Posted August 6, 2009 Author Share Posted August 6, 2009 (edited) I just figured it out! My @Scriptdir is in My Documents, so I tried a workarround by putting path in quotes: $RobocopyPID = Run (""""&@ScriptDir & "\robocopy.exe""", @ScriptDir, @SW_MAXIMIZE, $STDOUT_CHILD + $STDERR_CHILD) I don't like it, but for now, it works. Did I discover a bug? >_< Stefan, thanks for all your help. Cheers, Bostjan Edited August 6, 2009 by BoskoBuha Link to comment Share on other sites More sharing options...
99ojo Posted August 6, 2009 Share Posted August 6, 2009 I just figured it out! My @Scriptdir is in My Documents, so I tried a workarround by putting path in quotes: $RobocopyPID = Run (""""&@ScriptDir & "\robocopy.exe""", @ScriptDir, @SW_MAXIMIZE, $STDOUT_CHILD + $STDERR_CHILD) I don't like it, but for now, it works. Did I discover a bug? >_< Stefan, thanks for all your help. Cheers, Bostjan Hi, Run is always critical if you have blanks in your command. Funny, i have had tested the script in directory "This is a test". But i didn't get a fault, because robocopy was found over path variable. It is installed in Windows Ressource Kit. So i can't reproduce your fault. ;-)) Stefan Link to comment Share on other sites More sharing options...
BoskoBuha Posted August 6, 2009 Author Share Posted August 6, 2009 But i didn't get a fault, because robocopy was found over path variable. It is installed in Windows Ressource Kit. So i can't reproduce your faultYou can actually. Temporary move robocopy in your @ScriptDir. ;-)Anyway, I am relieved, but I still have much to learn...Cheers,Bostjan Link to comment Share on other sites More sharing options...
99ojo Posted August 6, 2009 Share Posted August 6, 2009 You can actually. Temporary move robocopy in your @ScriptDir. ;-)Anyway, I am relieved, but I still have much to learn...Cheers,Bostjan >_< I did.....;-))Stefan 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