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

  • Home
  • SEARCH
  • 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 7691139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:33:16+00:00 2026-05-31T20:33:16+00:00

I have a console application which can also open winform under certain conditions.Processing(its a

  • 0

I have a console application which can also open winform under certain conditions.Processing(its a database export utility) and be done either through form or commandline. but the form is always associated with command prompt. i mean when i close the console the form get closed as well.My requirement is that when form is launched , the command prompt is closed by itself without closing the form.

  [STAThread]
    public static void Main(string[] args)
    {

         if(hastolaunchform)
          {
                  Application.Run(new Form1());
           }

         else
           {
                       Console.WriteLine("started");
                        try
                        {
                            dataclass.extract();
                            console.writeline("finish");
                        }
                        catch (Exception e)
                        {

                            Console.WriteLine("An error occur");
                        }
             }

         }
  • 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-31T20:33:17+00:00Added an answer on May 31, 2026 at 8:33 pm

    What you have here is an app that has a gui or not.

    What you need is a gui version of it that optionally can be run from the CLI, ie it needs to be another exe, or the same exe with different command line parameters, though be careful with that, otherwise it could just keep launching another version of itself until windows dies.

    At least I think that’s what you are asking.

    CLI arguments

    MyApp.Exe –GUI

    –GUI will apears in args[1].

    So something like

    if (args.Contains["--GUI"])
    {
       Application.Run(new Form1());
    }
    else
    {
      if (hastolaunchForm)
      {
         // use Process.start to run another version of your app with --GUI parameter
         // and close
      }
      else
      {
         // do console stuff.
      }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a console based application which pulls files from a database and outputs
I have a console application which is parsing HTML documents via the WebRequest method
I have a console application which has target .NET 2.0 It is very short
I have a c++ console application which I would like to publish using clickonce.
In my console application have an abstract Factory class Listener which contains code for
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I'm about to start an application which will have both console and GUI interfaces.
I have an console application (that also is run as a service when deployed).
I have a simple console application which runs daily (called by windows task scheduler)
I have a console-based QCoreApplication which has timers and does socket communication and also

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.