none
How to start a console application from windows applcation.

    Question

  • Hi,
    I have two applications with me a windows application and a console application.
    Now I want
     1. When Valid user will login to the windows application.... the console application (which will work as a background process to retrive database) should start.
        -  How I can start a console application from a windows application, without showing the black screen of console application?

      2. When User will Logout from the windows application... the console application also should stop working.
       -     -  How I can stop the started console application from a windows application ?


    Thanks and regards,
    Tejaswini.



    Friday, January 08, 2010 12:18 PM

Answers

  • hi,

    System.Diagnostics.Process.Start("../consoleapplication file path/");
    Nagarjuna Dilip
    • Marked as answer by Jing0Moderator Tuesday, January 12, 2010 9:53 AM
    Saturday, January 09, 2010 5:35 AM
  • Hello TejaswiniJ,

    as said you can start and stop console application by using System.Diagnostics.Process class

    		System.Diagnostics.Process p = null;
    		private void Form1_Load(object sender, EventArgs e)
    		{
    			p = new System.Diagnostics.Process();
    			p.StartInfo.FileName = @"PathToYourConsoleApplication.exe";
    			// this should hide the console window    
    			p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                            // handle process finishing on its own 
    			p.Exited += new EventHandler(p_Exited);
                            // start process
    			p.Start();
    		}
    
    You can also check out this thread about hiding console app window:
    • Marked as answer by Jing0Moderator Tuesday, January 12, 2010 9:53 AM
    Saturday, January 09, 2010 12:40 PM

All replies

  • Hello TejaswiniJ,

    do you have to start a separate application for some reason or would it be ok just to start the background process in a separate thread ?

    regards, 
    Vladimir.
    Friday, January 08, 2010 1:22 PM

  • Hello Vladimir,
                 I want to start a separate application..not a back ground process.
    Can u help me now ?

    Regards,
    Tejaswini.
    Saturday, January 09, 2010 5:25 AM
  • hi,

    System.Diagnostics.Process.Start("../consoleapplication file path/");
    Nagarjuna Dilip
    • Marked as answer by Jing0Moderator Tuesday, January 12, 2010 9:53 AM
    Saturday, January 09, 2010 5:35 AM
  • Hello TejaswiniJ,

    as said you can start and stop console application by using System.Diagnostics.Process class

    		System.Diagnostics.Process p = null;
    		private void Form1_Load(object sender, EventArgs e)
    		{
    			p = new System.Diagnostics.Process();
    			p.StartInfo.FileName = @"PathToYourConsoleApplication.exe";
    			// this should hide the console window    
    			p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                            // handle process finishing on its own 
    			p.Exited += new EventHandler(p_Exited);
                            // start process
    			p.Start();
    		}
    
    You can also check out this thread about hiding console app window:
    • Marked as answer by Jing0Moderator Tuesday, January 12, 2010 9:53 AM
    Saturday, January 09, 2010 12:40 PM