The web program calls the EXE file-C #

Source: Internet
Author: User

// Call cmd for execution.
Private void process ()
{
PROCESS p = new process (); // load the CMD command line and pass the parameter execution
P. startinfo. filename = "cmd.exe"; // set the target to be called.ProgramOr file, filename attribute is not

P. startinfo. useshellexecute = false; // whether to start the process using the operating system shell program

P. startinfo. redirectstandardinput = true; // redirect standard input direction

P. startinfo. redirectstandardoutput = true; // redirect standard output direction

P. startinfo. redirectstandarderror = true; // whether to write process error output to

P. startinfo. createnowindow = false; // whether the CMD Command Prompt window is displayed
String stroutput = NULL; // receives the doscommand execution result
P. Start ();
P. standardinput. writeline (@ "cd d: \ projects \ COMIS \ cmp101 \ bin \"); // This is the doscommand to be executed
P. standardinput. writeline ("cmp101.exe 200805 ");
P. Dispose ();

}
// Directly execute
Private void process1 ()
{
System. Diagnostics. processstartinfo info = new system. Diagnostics. processstartinfo ();
Info. filename = "cmp101.exe"; // obtain or set the application or document to be started
Info. workingdirectory = "D:/projects/COMIS/cmp101/bin"; // gets or sets the initial directory of the process to be started.
Info. Arguments = "200805"; // gets or sets a set of command line parameters to be used when an application is started

Info. createnowindow = false; // obtain or set the value indicating whether to start the process in a new window
Info. verb = "open"; // get or set the predicate used to open the application or document specified by the filename attribute
Info. windowstyle = system. Diagnostics. processwindowstyle. Normal; // gets or sets the window status used when the process is started.
Info. useshellexecute = true; // gets or sets a value indicating whether to start the process using the operating system shell program
System. Diagnostics. process. Start (Info );
}
// Use the Stored Procedure Call of the database
Private void process3 ()
{
String SQL = "xp_mongoshell 'd:/projects/COMIS/cmp101/bin/cmp101.exe 200805 '";
}

Related Article

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.