Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:45:40+00:00 2026-05-27T11:45:40+00:00

In order to start another instance of my program I did something like: private

  • 0

In order to start another instance of my program I did something like:

private void button1_Click(object sender, EventArgs e)
{
    Process p = new Process();
    p.StartInfo.FileName = Application.ExecutablePath;
    p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
    p.Start();
}

And found that stopping the debugger didn’t stop the new window, only the first (-launching) window.

How do I programmatically get the new process to be “under” VS?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:45:40+00:00Added an answer on May 27, 2026 at 11:45 am

    Since you’re starting your own program a second time, you know it is a GUI. You can keep the Process reference around and call CloseMainWindow (or Kill) on each of them in your FormClosing event handler:

    private List<Process> children = new List<Process>();
    
    private void button1_Click(object sender, EventArgs e)
    {
        Process p = new Process();
        p.StartInfo.FileName = Application.ExecutablePath;
        p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
        p.Start();
    
        children.Add(p);
    }
    
    private Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        foreach (Process p in this.children)
        {
            // posts WM_CLOSE to the main handle of the process
            // which allows a graceful exit, as if the user clicked [X]
            p.CloseMainWindow();
            // p.Kill(); // less graceful, just kill
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my C++/winapi program I use an event object to detect if an instance
I am using jquery ui datepicker in order to populate start and end dates
Is there any way to start foobar.js WSH-script in order that standard Task Manager
I've got how to copy one file to another from start, but how could
I have a situation where I'm starting a process in my code in order
OK, so let start from the beginning. For instance, I'm developing some big project.
Two functions need to execute in Javascript, and one should start when another has
I have a rather large SQL file which starts with the byte order marker
order by in query is taking to much time in MySQL. SHOW PROFILES shows
Order by descending is not working on LINQ to Entity In the following Query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.