howto make a console app start with window minimized

P

Paul

Hi,

I have a console app which is simply called from another app which passes a
filename to it for processing. It does not display anything or require any
input. All errors are sent to the eventlog.

As this app is really just a wrapper for a class library I don't need it
"popping" up on the console and would like it to be either invisible or for
the console window to run minimized in the taskbar.

Any suggestions on how I might achieve this?

Thanks,

Paul
 
G

Guest

I have a console app which is simply called from another app which passes a
filename to it for processing. It does not display anything or require any
input. All errors are sent to the eventlog.
As this app is really just a wrapper for a class library I don't need it
"popping" up on the console and would like it to be either invisible or for
the console window to run minimized in the taskbar.

I run an exe file without a window as follows:

Dim p As New Process
With p.StartInfo
.FileName = "yourprogname.exe"
.Arguments = "yourfilename"
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
Try
p.Start()
's = p.StandardOutput.ReadToEnd()
'p.WaitForExit()
Catch ex As Exception
's = ex.ToString
End Try

Toward the end, a few lines are commented out. These lines read stdout of
the launched program and cause the launching program to wait for completion.
If you want to launch and forget, then leave them out.
 
P

Paul

Thanks AMercer,

I'm not sure where to put this code. I stuck it in the Main() and it still
launches the console window before executing the process object.

I should mention that the process that calls my routine is a 3rd party
product that simply runs an executable specified property) when a particular
event occurs.

I suspect that I could use your code in the calling routine but
unfortuanately I don't have that option.

Am I trying to use the code incorrectly?

Thanks,

Paul
 
G

Guest

I suspect I didn't understand your question, and I'm not sure I do now.
Assume exe P1 launches exe P2. The code I specified resides in P1 and is
used to launch a windowless P2.

If this doesn't help you (ie you are coding P2 and P1 is someone else's),
then you are at the mercy of how P1 is coded. There may be a way for P2 to
determine how it was launched and influence its operation, but I have no
experience in that. Maybe you could change P2 into windows program, and you
could control your visibility destiny directly. You might consider that - it
is legitimate for a windows exe (vice a console exe) to run to completion
without ever creating a window.
 
P

Paul

Hi AMercer,

Thanks for that. Yes P2 = my code and P1 = someone else's. I will try the
"windowless" windows forms approach and see how I get on.

Thanks again,

Paul
 
P

Paul

Hi AMercer,

Thanks for the help. The last bit about the window app without a form sent
me in the right direction.
I simply changed the project output to Windows App. and no more console
window. Great.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top