Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
1.04/5 (4 votes)
See more:
Hello,

How do I command line arguments for run two exe or executable file in c# .net windows application?

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted
Comments
sid2x 24-Jun-14 8:56am    
Didn't catch what you're trying to convey. Do you want to grab command line arguments from a C# application or do you want to execute another process and give the appropriate command line arguments?
[no name] 24-Jun-14 9:01am    
I want run one exe run in another exe but external exe should not be run manually using c# .net windows application.
Dave Kreskowiak 24-Jun-14 9:11am    
That still did not make any sense. Executables do not run inside other executables.
Suvabrata Roy 24-Jun-14 9:20am    
what you want?

1. Run one executable from another executable
2. Control/Exchange data from one application to another application
Sergey Alexandrovich Kryukov 24-Jun-14 13:50pm    
The question lack the verb: do what?
—SA

Try:
C#
Process p1 = new Process();
p1.StartInfo.FileName = @"D:\Temp\MyFirstExe";
p1.StartInfo.Arguments = "MyFileName.txt -o myOutputFile.txt";
p1.Start();
Process p2 = new Process();
p2.StartInfo.FileName = @"D:\Temp\MySecondExe";
p2.StartInfo.Arguments = "\"Another set of arguments\" \"to pass through\"";
p2.Start();
 
Share this answer
 
Comments
[no name] 24-Jun-14 9:07am    
Is it running for my case:-
Second external exe should not be run manually.
It's should be run only internal exe only.
Create an argument with a password, so you are the only one who can run the second exe.

MySecondExe -p password -o options
 
Share this answer
 
Comments
Dave Kreskowiak 24-Jun-14 9:49am    
That's not going to work because you can easily get the password from the command line that was used to launch the process using Task Manager.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900