views:

55

answers:

4

Can a VB.NET Windows Forms Application be configured so that when run from the command-line, the command-line waits until the application exits before showing the next prompt?

A: 

I think the answer is No, but a console application can show forms.

Mark Hurd
A: 

Unless the command-line is your own console app, then no.

I suppose you could create a console app that shelled out to the windows forms app... a bootstrapper of sorts. If the console app were to be launched by command-line, it might do the trick.

Mike L
+4  A: 

You can change the command to start your application from the command line to:

start /wait YourApplication.exe

In general the command line behavior depends on the subsystem your application is using (Console/Windows). As an Application with the subsystem Windows doesn't have standard input/output streams, there is no need for the console to wait for them.

But you can change your application to be a console app and use your existing forms as usual. This link shows an example.

Frank Bollack
+1  A: 

The code after Application.Run(new Form1()); is only run after the application has been exited. No configuration needed.

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        string s = "test string";
        s.Trim();
    }
CnTwo