2011-03-01 3 views
0

i besoin d'exécuter le programme avec la commande par exemple dans Windows CE ou Windows Mobilecomment exécuter le programme avec la commande?

: RunMe.exe true ou RunMe.exe false

si le programme retourne vrai que le programme fera quelque chose et si le programme retourne false

le programme fera autre chose.

comment puis-je accomplir cela?

Répondre

1

Votre question n'est pas claire.

Si vous souhaitez écrire un tel programme, utilisez le string[] args paramètre à Main().
(ou appelez Environment.GetCommandLineArguments())

Si vous voulez terme un tel programme, appelez Process.Start.

0

De this question (qui a obtenu à partir 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(); 
0

Si vous voulez faire cela sans écrire un autre programme, vous pouvez créer un fichier de raccourci pour lancer votre application avec les options de ligne de commande souhaitées.

Le format d'un fichier de raccourci ressemble à ceci:

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

Par exemple:

40#\Windows\MyApp.exe parameter1 parameter2

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

Questions connexes