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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:33:54+00:00 2026-05-27T06:33:54+00:00

I have a Windows app that I’ve written in C# 4 and WPF; I’ve

  • 0

I have a Windows app that I’ve written in C# 4 and WPF; I’ve now been asked if I can add a commandline parameter (e.g. /console) that would force it to run as a console app so it can be run by a task scheduler.

Is this possible with modern apps? Or do I need to create a separate console app?

UPDATE: can I just emphasise that this is a WPF application. There is no convenient static void Main(string[] args) entry point to hook into. But the PM would still like the app to have the ability to run from the commandline…

FINAL UPDATE: the trick, as pointed out by @RodH257, is that the WPF app codegens the expected static void Main. You can add your own class with a method of the same name and in the project build properties, set it as the startup object for the executable. You’ll also need the [STAThread] attribute on the method so that WPF will run properly too.

  • 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-27T06:33:55+00:00Added an answer on May 27, 2026 at 6:33 am

    You can either turn it into a console application and manually show the first WPF dialog. just as you would if you were creating a DLL and starting a WPF window, as per below

     static class Program
    {
        static void Main(params string[] args)
        {
            if (args.Length > 0)
            {
               //do stuff here
                return;
            }
              Window1 window = new Window1();
              window.ShowDialog();
        }
    }
    

    OR, have a look at this link for editing the entrypoint on your current WPF project and act based on arguments
    How to write custom Main method for a WPF application?

    EDIT:
    Updated the post to make it more clear for the exact situation described.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Forms app, that has a single ElementHost containing a WPF
We have a windows MFC app that is written against an access database on
I have a Windows Forms app that is able to open up a console
I have an AIR/Flex app that can have multiple windows (s:Window instances) open at
I have a windows console app (that accepts parameters) and runs a process. I
i have code written in c++. its a console app that takes an input
I have a windows console app that is supposed to run without restarts for
I have a windows app that runs correctly in my PC that is 96DPI
This is the situation. I have a windows form app that uses an access
I have a windows mobile app (mymobiler) that i am trying to install and

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.