C # calling external programs

Source: Internet
Author: User

// It seems very simple .. A program is an interface. A prompt on the left shows a checkbox prompting the user "I know, please do not display it again". A button running QQ is displayed on the right. But it took about four hours. Debugging is often correct, but sometimes it is not reflected after the button is clicked,

// The external program cannot be run. // The Events () method is better, but this may happen occasionally. System. Threading. Thread. Sleep (2000); solved .. There is no turning.

Public static void RunQQ ()
{
// An example is a Process type, which initiates a pipeline.
Process p = new Process ();
String command = @ "d: \ sysset \ menu \ runqq. bat ";
// The Process class has a StartInfo atomicity. This is ProcessStartInfo class, which includes some attention and methods. We will use its attention below:

P. StartInfo. FileName = command; // set the program name
P. StartInfo. Arguments = "/c" + string. Empty; // you can specify the number of rows in the program.
P. StartInfo. UseShellExecute = false; // use of related Shell
P. StartInfo. RedirectStandardInput = true; // redirect the standard ingress
P. StartInfo. RedirectStandardOutput = true; // redirect the mark to export
P. StartInfo. RedirectStandardError = true; // redirect zookeeper output
P. StartInfo. CreateNoWindow = true; // you can specify a non-empty window.

P. Start (); // dynamic

// P. StandardInput. WriteLine (command); // you can also use this method to export the command to be executed.
// P. StandardInput. WriteLine ("exit"); // you must remember to add Exit. Otherwise, the next line of program will become available.

}

// It is very important .. Is used

Application. DoEvents (); System. Threading. Thread. Sleep (2000); Directory. CreateDirectory (@ "e: \ OK"); // create a folder

If (! Directory. Exists (@ "e: \ OK") // create a folder if the folder does not exist
{
// Display the form.
Application. Run (new Form1 ());

}

 

 

 

 

 

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.