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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:24:23+00:00 2026-05-25T02:24:23+00:00

I currently have an application with a GUI. Would it be possible to use

  • 0

I currently have an application with a GUI.

Would it be possible to use this same application from the commandline (without GUI and with using parameters).

Or do I have to create a separate .exe (and application) for the commandline tool?

  • 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-25T02:24:23+00:00Added an answer on May 25, 2026 at 2:24 am
    1. Edit your project properties to make your app a “Windows Application” (not “Console Application”). You can still accept command line parameters this way. If you don’t do this, then a console window will pop up when you double-click on the app’s icon.
    2. Make sure your Main function accepts command line parameters.
    3. Don’t show the window if you get any command line parameters.

    Here’s a short example:

    [STAThread]
    static void Main(string[] args)
    {
        if(args.Length == 0)
        {
            Application.Run(new MyMainForm());
        }
        else
        {
            // Do command line/silent logic here...
        }
    }
    

    If your app isn’t already structured to cleanly do silent processing (if all your logic is jammed into your WinForm code), you can hack silent processing in ala CharithJ’s answer.

    EDIT by OP
    Sorry to hijack your answer Merlyn. Just want all the info here for others.

    To be able to write to console in a WinForms app just do the following:

    static class Program
    {
        // defines for commandline output
        [DllImport("kernel32.dll")]
        static extern bool AttachConsole(int dwProcessId);
        private const int ATTACH_PARENT_PROCESS = -1;
    
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);
    
            if (args.Length > 0)
            {
                Console.WriteLine("Yay! I have just created a commandline tool.");
                // sending the enter key is not really needed, but otherwise the user thinks the app is still running by looking at the commandline. The enter key takes care of displaying the prompt again.
                System.Windows.Forms.SendKeys.SendWait("{ENTER}");
                Application.Exit();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new QrCodeSampleApp());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
Currently I have an application that receives an uploaded file from my web application.
We currently have developed an application using WCF. Our clients make connections to different
Currently I have a web application where a user can use dropdown lists to
I'm writing an application that has an SWT GUI currently, but would like the
I currently have two separate programs: (1) a GTK GUI; (2) a Glut application
I'm currently developing a web application using Struts2 framework. This application requires to dynamically
I'm currently using QTCreator version 4.7.4 to write a GUI application which plays AVI
I'm currently developing a GUI for a Java-application that I've created. I would like
I currently have an application which needs to have an awareness of which monitor

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.