By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,045 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,045 IT Pros & Developers. It's quick & easy.

howto make a console app start with window minimized

P: n/a
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
Jan 12 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
> 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.

Jan 12 '06 #2

P: n/a
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

"AMercer" <AM*****@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
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.

Jan 13 '06 #3

P: n/a
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.

Jan 13 '06 #4

P: n/a
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
"AMercer" <AM*****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
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.

Jan 16 '06 #5

P: n/a
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
"AMercer" <AM*****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
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.

Jan 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.