Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Run An Executable By Pressing a Button 1

Status
Not open for further replies.

BoulderBum

Programmer
Jul 11, 2002
2,179
US
I'm a total C# newb, and for one of my first projects, I want to make a simple form that runs various programs when the user presses various buttons.

Will anyone give me the name of the object(s) I need to get me started (and perhaps give a simple example).
 
You need to start a process like this:

Process callmyApp = new Process();
callmyApp.StartInfo.FileName = "app.exe"; //Your applikation in here
callmyApp.StartInfo.Arguments = "";//if you have arguments you need to pass to the app they goe here
callmyApp.Start();

I think you need to include (using) System.Diagnostics for this to work.

Hope I could help, Stephan
 
Mega sweet! Process.Start() appears to behave like a C# version of ShellExecute. Are there any notable differences?
 
If I am not incorrect Process allows you to redirect standard error and output from applications, also supression of errors and windows(Not showing a window when started). Also you can wait till end or have events triggered when Processes stop.

I'm not too familiar with shellexecute, but I don't recall it having these options.

-Regards,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top