Share via

Run Application use C#

MiPakTeh 1,476 Reputation points
2021-05-21T14:54:09.857+00:00

I have 2 program. App_.exe and Main_
What I try to do;
Program Main_ can run the Program App_.exe.

My problem is how to call the class "StartStop_" for button2 in code Form1.
It use for close the program App_.exe.

Thank.
98721-asking.txt

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

Answer accepted by question author

Daniel Zhang-MSFT 9,661 Reputation points
2021-05-24T02:17:34.723+00:00

Hi MiPakTeh-6272,
You need to get the App_.exe process through the start method firstly, and then pass it to the stop method.
Please refer to the follwing code:

Process process;  
private void button1_Click(object sender, EventArgs e)  
{  
    process = startstop.StartStop_.Start(@"D:\Project\source\repos\App_\App_\bin\Debug\App_.exe");  
  
}  
       
private void button2_Click(object sender, EventArgs e)  
{  
    startstop.StartStop_.Stop(process);  
}  

Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.