tjscience / RoboSharp

RoboSharp is a .NET wrapper for the awesome Robocopy windows application.
MIT License
216 stars 67 forks source link

Minimized window #74

Closed splendid25 closed 3 years ago

splendid25 commented 5 years ago

Hi, when start from a WinForms app, Robocopy.exe is display in a normal window on top of the current form. Is is possible to start Robocopy.exe minimized ?

bruceburge commented 5 years ago

Please post the code of how you are using robosharp, in my experience there is no window created.

splendid25 commented 5 years ago

Sure here it is :

using (var copyCommand = new RoboCommand())
{
    copyCommand.CopyOptions.Source = originalPath;
    copyCommand.CopyOptions.Destination = targetPath;
    copyCommand.CopyOptions.CopySubdirectories = true;

    copyCommand.RetryOptions.RetryCount = 1;
    copyCommand.RetryOptions.RetryWaitTime = 2;

    var task = copyCommand.Start(domain, user, pwd);
    task.Wait();
}

It seems the window is displayed on the task.Wait(). I use RoboCopy from a .NET4.0 Winform App. Is there another way to wait synchronously ?

Thanks

bruceburge commented 5 years ago

I use a very similar set up, and don't see any console window. What does the console window have written in it? have you changed any other settings related to robocopy?

Have you looked at the example on the Readme page?

You can add a wait to that codes starting task and shouldn't see a console window

splendid25 commented 5 years ago

OK I found details on the issue. If I run this there is no window :

var task = copyCommand.Start();

And with another user running robocopy, a console window appears, with the title 'C:\Windows\system32\Robocopy.exe' :

var task = copyCommand.Start(domain, user, pwd);

In my use case, the user running the program won't have permissions to access the folders, so I need to run Robocopy as another user.