0

We have a legacy app which should have been a service but built as a service and when it's running I don't want the console to be displayed.

Is there any way of hiding the console window in a windows console application and/or minimising the console window to system tray (not taskbar), then bring it back when double clicked in the system tray? I have already done this with a winform but not sure if it's possible to do it on a console app.

Thanks

03Usr
  • 3,335
  • 6
  • 37
  • 63
  • You want to compile it without window or you want just to hide the window for the current build? – Havenard May 04 '13 at 17:30
  • need to compile with the window and once it is running then hide it with a command or by minimising etc.. – 03Usr May 04 '13 at 17:34
  • @03Usr When you say "compiled as a service", what exactly do you mean? – Jesse May 05 '13 at 16:12
  • @jesse Not Sure where you have seen the text "compiled as a service"? – 03Usr May 05 '13 at 18:09
  • @03Usr I mean "built". – Jesse May 05 '13 at 21:53
  • This is different than the others, in this one I am asking if it is possible to minimise the console window to system tray (not taskbar), then bring it back when double clicked in the system tray, none of the other questions are answering this. – 03Usr May 07 '13 at 21:39

2 Answers2

1

This will hide your console window:

  ProcessStartInfo startInfo = new ProcessStartInfo();
  startInfo.CreateNoWindow = true;
  startInfo.UseShellExecute = false;
  startInfo.FileName = "YourApp.exe";
  startInfo.CreateNoWindow = true;
  startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Santosh Panda
  • 7,235
  • 8
  • 43
  • 56
0

You can tell a program to start hidden by defining some startup flags.

You can for instance write a startup hidden.vbs script with this code:

Set oShell = CreateObject("WScript.Shell")
oShell.Run "program.exe", 0

With this little script, program.exe is supposed to start hidden. It will display in the process list, but won't be visible as a window unless it was coded to enforce doing so.

Havenard
  • 27,022
  • 5
  • 36
  • 62