hello guys can anyone tell me how to open a executable file in Visual-studio using Button
like when i click the button it will open the calculator or notepad :)

- 101
- 2
- 3
- 8
-
Have you tried Process.Start? Also, take a look http://stackoverflow.com/questions/9679375/run-an-exe-from-c-sharp-code – Deepu Madhusoodanan Jun 20 '13 at 07:02
-
2The amount of answers on this question is pretty huge. Yukimoto Otomikuy, are you sure you used the Googles before posting this question? ;) – Jun 20 '13 at 07:05
4 Answers
Use Process.Start
.
Process.Start("notepad.exe");
From MSDN:
Starting a process by specifying its file name is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the file name does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system.

- 1
- 1

- 132,704
- 33
- 254
- 328
-
1
-
Process.Start("notepadd.exe").WaitForExit(); // if you want to block the caller . – amin Jul 03 '14 at 10:14
You can use Process.Start
method like;
Starts a process resource and associates it with a Process component.
Process.Start("calc.exe");
Process.Start("notepad.exe");
Starting a process by specifying its file name is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the file name does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system. For example the file name can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated.doc files with a word processing tool, such as Microsoft Word. Similarly, in the same way that the Run dialog box can accept an executable file name with or without the .exe extension, the .exe extension is optional in the fileName parameter. For example, you can set the fileName parameter to either "Notepad.exe" or "Notepad".

- 97,193
- 102
- 206
- 364
-
Funny, it's like every edit I make shows up in your answer. Also funny is the fact that this isn't the first time I've said this to you. – Jonathon Reinhart Jun 20 '13 at 07:03
-
-
@JonathonReinhart It is too normal because we both looked in _MSDN_ page getting better explanation for OP. But what you clearly said here; "_Hey Soner, you just copied my answer_" This is not cool at all. This is not a though question, anyone can answer it. So the answers can have nearly timestamps. It is too normal. That doesn't mean they just copied one of another answers. Stop blaming people with this kind of bad attitudes.. – Soner Gönül Jun 20 '13 at 07:13
-
Right. But I just spent the last 12 minutes unsuccessfully trying to find the question this last happened on. Perhaps I'm mistaken; *if* that is the case, then I apologize. – Jonathon Reinhart Jun 20 '13 at 07:15
-
Ah, it seems I was [not mistaken](http://stackoverflow.com/questions/16559937/). Soner, I understand it is easily possible for two answers on a question this simple to end up looking very similar. However, I'm going to respectfully ask that you not continually massage your answers to look like mine. – Jonathon Reinhart Jun 20 '13 at 07:27
Use the System.Diagnostics.Process.Start() method.
Check out this article on how to use it.

- 1
- 1
Use the above
// run notepad
System.Diagnostics.Process.Start("notepad.exe");
//run calculator
System.Diagnostics.Process.Start("calc.exe");

- 1,960
- 1
- 17
- 30