System.Diagnostics.Process interrupt

Posted on 2006-05-06
Last Modified: 2012-06-21

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 = 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.

Question by:Donnie4572
    LVL 48

    Accepted Solution

    Hide DOS window by the following way:

    procusers.StartInfo.CreateNoWindow = true;
    LVL 48

    Expert Comment

    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

    LVL 12

    Author Comment


    Good idea. How does this solve my problem. I need to prgramatically exit the doss window. Example: a button that safely exits procusers.Start.
    LVL 48

    Expert Comment

    This prevents user to close DOS window, I understand that this is the problem.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now