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 8788783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:13:27+00:00 2026-06-13T22:13:27+00:00

I am trying to open a console application in visual studio built in C#.

  • 0

I am trying to open a console application in visual studio built in C#. As soon as I open it, it closes immediately.

I know windows sets this is a a safety default (atleast I think). How do I fix this?

I know I can compile it and create a shortcut and modify the target so it has the location of the command prompt in it before the applications location. Although the programmer who created this has it generating information into the output of visual studio, so it’s imperative that I only open it there.

It happens with most applications and not just in visual studio, just in this case I need it to open in VS 2010. I am using Windows 7.

  • 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-06-13T22:13:29+00:00Added an answer on June 13, 2026 at 10:13 pm

    This is an ancient problem and has inspired several funny cartoons:

    enter image description here

    Let’s fix it. What you want to do is prompt the user to press the Any key when the console app was started from a shortcut on the desktop, Windows Explorer or Visual Studio. But not when it was started from the command processor running its own console. You can do so with a little pinvoke, you can find out if the process is the sole owner of the console window, like this:

    using System;
    
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("Working on it...");
            //...
            Console.WriteLine("Done");
            PressAnyKey();
        }
    
        private static void PressAnyKey() {
            if (GetConsoleProcessList(new int[2], 2) <= 1) {
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
        }
    
        [System.Runtime.InteropServices.DllImport("kernel32.dll")]
        private static extern int GetConsoleProcessList(int[] buffer, int size);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running a console application in MS Visual Studio 2010 in Windows 7
I built a console application and I'm trying to test if my application works
Hey all i am trying to understand how to keep my console app open
I'm trying to open a file for input in Excel with this line :
All I'm trying to do is open a very simple application that is supposed
I'm trying to redirect stdin and stdout of a console application, so that I
I know it sounds stupid but: I've found this application written on Mono and
I'm trying to open a JMX connection to java application running on a remote
I am trying to run this in Chrome/Firefox Console but not having any luck.
I am running windows 7 and I am trying to get this IDE to

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.