简体   繁体   中英

how to run program with command?

i need to run program with command in Windows-CE or Windows-Mobile

for example: RunMe.exe true or RunMe.exe false

if the program returns true the program will do something and if the program returns false

the program will do something else.

how can I accomplish this ?

Your question is unclear.

If you want to write such a program, use the string[] args parameter to Main() .
(Or call Environment.GetCommandLineArguments() )

If you want to run such a program, call Process.Start .

If you want to do this without writing another program, you can create a shortcut file to launch your application with the desired command-line options.

The format of a shortcut file looks like this:

[number of ASCII characters after pound sign allocated to command-line arguments]#[command line] [optional parameters]

For example:

40#\\Windows\\MyApp.exe parameter1 parameter2

see: http://msdn.microsoft.com/en-us/library/ms861519.aspx

From this question (which got it from msdn ):

// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "YOURBATCHFILE.bat";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM