Jump to content

RunWait will not execute robocopy


Recommended Posts

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 by BoskoBuha
Link to comment
Share on other sites

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

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

post-42353-12494702833557_thumb.jpg as result.

;-))

Stefan

Link to comment
Share on other sites

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 by BoskoBuha
Link to comment
Share on other sites

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 by BoskoBuha
Link to comment
Share on other sites

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

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

You 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...