C # Invoke executable (. Bat,.exe ...)

Source: Internet
Author: User
    In the process of server development, we often need to open a number of black-box testing, in the folder to find these executables is a waste of time to
bring the personal experience is also very bad, we can use C # to make some gadgets to improve this situation, such as the need to open a number of black boxes
Executable file dropped in the button, although the function is very simple, but bring personal experience is moving, C # Grammar is not introduced, I here
mainly about how to invoke the executable file
    The required header file
    using System.Diagnostics;

    Here is the folder directory
    string TargetPath = string of the executable file to invoke. Format (@ "folder path");

    Process: Provides access to local and remote processes and enables you to start and stop Local system processes process processing
    = new process ();

    Initializes some of the underlying information process for an executable file
    . Startinfo.workingdirectory = TargetPath; Initializes the folder information process for the executable file
    . Startinfo.filename = "executable file name. suffix"; Initialize executable file name

    //When we need to pass parameters to an executable file we can set this parameter
    ///"PARA1 para2 para3" parameter as a string, with each parameter separating the process by a space
    . startinfo.arguments = "Para1 para2 para3";
    Process. Startinfo.useshellexecute = true;        Start the executable process by using the operating system shell startup processes
    . Start ();
    With the above code, we can invoke any executable file.
I personally like the various server startup information and database information integration in the gadget, each time to test the time
to click a few buttons can be, to avoid always go to the folder to find the necessary startup files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.