Link to home
Start Free TrialLog in
Avatar of Donnie4572
Donnie4572Flag for United States of America

asked on

System.Diagnostics.Process interrupt

Hi,

I have this problem:

Dim procusers As New System.Diagnostics.Process()
       procusers.StartInfo.FileName = "C:\test\robocopy.exe"
       procusers.StartInfo.Arguments = """/JOB:C:\test\test1"""
        procusers.Start()
        procusers.WaitForExit(True)
        procusers.Close()
        procusers.Dispose()
        procusers = Nothing

This is running a copy of about 2TB of data and is working well. But, for what ever reason if I stop the program by exiting the dos window it is causing problems on the windows box and the server needs rebooting.

Is there some code I chould use to interrupt this program so it shuts down properly.

I assume that because the app is writing to disk at the time it exits that this is causing the problem.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlexFM
AlexFM

If you want to show user process output, you can redirect it and show in the program window instead of DOS window. See ProcessStartInfo.RedirectStandardOutput Property:

procusers.StartInfo.RedirectStandardOutput = true

Avatar of Donnie4572

ASKER

Thanks,

Good idea. How does this solve my problem. I need to prgramatically exit the doss window. Example: a button that safely exits procusers.Start.
This prevents user to close DOS window, I understand that this is the problem.