Home All Groups Group Topic Archive Search About

[2.0] Hide a console application

Author
20 Oct 2006 12:57 PM
Freddyboy
Hi, I have a console application and I would like to hide it when it's running.
Of course I took a look into the StartInfo property of the Process Class
(CreateNoWindow, WindowsStyle) but when I start my application, the dos
windows is still visible.

Process p = Process.GetCurrentProcess();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

This application is started by an other program which is not developped in
..NET so I can't create a ProcessStartInfo object and set CreateNoWindow and
WindowsStyle. Anyway I haven't source code.

Does someone have an idea or the solution for me ?

Thanks

Fred

Author
20 Oct 2006 1:23 PM
Kevin Spencer
Unless your app starts the process, the window cannot be hidden.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

Show quote
"Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message
news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com...
> Hi, I have a console application and I would like to hide it when it's
> running.
> Of course I took a look into the StartInfo property of the Process Class
> (CreateNoWindow, WindowsStyle) but when I start my application, the dos
> windows is still visible.
>
> Process p = Process.GetCurrentProcess();
> p.StartInfo.CreateNoWindow = true;
> p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
>
> This application is started by an other program which is not developped in
> .NET so I can't create a ProcessStartInfo object and set CreateNoWindow
> and
> WindowsStyle. Anyway I haven't source code.
>
> Does someone have an idea or the solution for me ?
>
> Thanks
>
> Fred
Author
20 Oct 2006 2:03 PM
Freddyboy
Thanks for your answer Kevin.

Show quote
"Kevin Spencer" wrote:

> Unless your app starts the process, the window cannot be hidden.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Chicken Salad Shooter
> http://unclechutney.blogspot.com
>
> A man, a plan, a canal, a palindrome that has.. oh, never mind.
>
> "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message
> news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com...
> > Hi, I have a console application and I would like to hide it when it's
> > running.
> > Of course I took a look into the StartInfo property of the Process Class
> > (CreateNoWindow, WindowsStyle) but when I start my application, the dos
> > windows is still visible.
> >
> > Process p = Process.GetCurrentProcess();
> > p.StartInfo.CreateNoWindow = true;
> > p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
> >
> > This application is started by an other program which is not developped in
> > .NET so I can't create a ProcessStartInfo object and set CreateNoWindow
> > and
> > WindowsStyle. Anyway I haven't source code.
> >
> > Does someone have an idea or the solution for me ?
> >
> > Thanks
> >
> > Fred
>
>
>
Author
20 Oct 2006 8:14 PM
Michael D. Ober
Iterate through the process list and get your target process.  Then use API
calls to get the window handle to the process and hide it.

Mike.

Show quote
"Kevin Spencer" <spam@uce.gov> wrote in message
news:eNG2QrE9GHA.4408@TK2MSFTNGP02.phx.gbl...
> Unless your app starts the process, the window cannot be hidden.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Chicken Salad Shooter
> http://unclechutney.blogspot.com
>
> A man, a plan, a canal, a palindrome that has.. oh, never mind.
>
> "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message
> news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com...
>> Hi, I have a console application and I would like to hide it when it's
>> running.
>> Of course I took a look into the StartInfo property of the Process Class
>> (CreateNoWindow, WindowsStyle) but when I start my application, the dos
>> windows is still visible.
>>
>> Process p = Process.GetCurrentProcess();
>> p.StartInfo.CreateNoWindow = true;
>> p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
>>
>> This application is started by an other program which is not developped
>> in
>> .NET so I can't create a ProcessStartInfo object and set CreateNoWindow
>> and
>> WindowsStyle. Anyway I haven't source code.
>>
>> Does someone have an idea or the solution for me ?
>>
>> Thanks
>>
>> Fred
>
>
Author
20 Oct 2006 1:53 PM
Chris Fulstow
Maybe you could build your application as a Windows Service instead?
http://msdn2.microsoft.com/en-us/library/zt39148a.aspx

--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/


Freddyboy wrote:
Show quote
> Hi, I have a console application and I would like to hide it when it's running.
> Of course I took a look into the StartInfo property of the Process Class
> (CreateNoWindow, WindowsStyle) but when I start my application, the dos
> windows is still visible.
>
> Process p = Process.GetCurrentProcess();
> p.StartInfo.CreateNoWindow = true;
> p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
>
> This application is started by an other program which is not developped in
> .NET so I can't create a ProcessStartInfo object and set CreateNoWindow and
> WindowsStyle. Anyway I haven't source code.
>
> Does someone have an idea or the solution for me ?
>
> Thanks
>
> Fred
Author
20 Oct 2006 3:12 PM
Ben Voigt
"Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message
news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com...
> Hi, I have a console application and I would like to hide it when it's
> running.
> Of course I took a look into the StartInfo property of the Process Class
> (CreateNoWindow, WindowsStyle) but when I start my application, the dos
> windows is still visible.

If you don't need a console window, make it not a console application.  A
Forms app isn't required to actually show a Form or run the event loop.

Show quote
>
> Process p = Process.GetCurrentProcess();
> p.StartInfo.CreateNoWindow = true;
> p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
>
> This application is started by an other program which is not developped in
> .NET so I can't create a ProcessStartInfo object and set CreateNoWindow
> and
> WindowsStyle. Anyway I haven't source code.
>
> Does someone have an idea or the solution for me ?
>
> Thanks
>
> Fred
Author
23 Oct 2006 7:21 AM
Freddyboy
Thanks all for your answers.
In fact that's rigth I changed my console application to a "form
application" without start a "form" and my application works like I want.

Thanks

Best Regards

Fred

Show quote
"Ben Voigt" wrote:

> "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message
> news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com...
> > Hi, I have a console application and I would like to hide it when it's
> > running.
> > Of course I took a look into the StartInfo property of the Process Class
> > (CreateNoWindow, WindowsStyle) but when I start my application, the dos
> > windows is still visible.
>
> If you don't need a console window, make it not a console application.  A
> Forms app isn't required to actually show a Form or run the event loop.
>
> >
> > Process p = Process.GetCurrentProcess();
> > p.StartInfo.CreateNoWindow = true;
> > p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
> >
> > This application is started by an other program which is not developped in
> > .NET so I can't create a ProcessStartInfo object and set CreateNoWindow
> > and
> > WindowsStyle. Anyway I haven't source code.
> >
> > Does someone have an idea or the solution for me ?
> >
> > Thanks
> >
> > Fred
>
>
>

AddThis Social Bookmark Button