473,466 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

howto make a console app start with window minimized

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
5 9550
> 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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
3
by: Mike Oliszewski | last post by:
I am attempting to install the MSDE (SQL 2000) as a part of our application. This requires that you run the MSDE setup.exe program from a Console mode application, it just hangs forever part way...
1
by: Console guy | last post by:
How do I force a console application to be minimized upon launch? I have a C# application which starts a console application via the following syntax: System.Diagnostics.Process.Start("Console.exe")...
2
by: Derrick | last post by:
Is there anywhere I can set a CSharp console application to run minimized? Class attribute maybe? I looked thru the project properties and didn't see anything. Thanks in advance! Derrick
19
by: Oliver Neumann | last post by:
Hello, im new to c# and i got an app with a notifyicon. Now i want to start the app only with the notifyIcon, so that the Main-Form doesnt show up. The form itself is used at the entrance...
5
by: Scott | last post by:
Hi everyone, I have a c# console app that when run through an autorun.inf file, launches a web page from the CD. It works just fine but I would like the console window minimized on startup....
7
by: Abelard | last post by:
How do I programmatically minimize the console window in a VB .NET console application?
1
by: Pia Stevens | last post by:
A program opened at start a console window. How can I automatically minimized this window to Systray (not Taskbar)? Pia
5
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Dear all, I'd like to know if there is any method to minimize command mode window when a console program is running. In my case, there are several console programs which run periodically in...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.