2

I'm writing an embedded powershell host in C# using VS13 (Windows Application NOT console app). I can invoke powershell commands just fine. The issue I'm having is that when the invoke function handles a console command like ping, netstat, etc. it triggers an instance of conhost.exe to be created. This is normal behavior for Windows 7 and above from my research so far, but when conhost starts up, it briefly flashes a console on the screen.

Is there a way to have conhost start-up without flashing the console window initially? Keep in mind that I'm handling user input into the powershell pipeline so testing for each command, and starting a new process is probably not practical.

RG5
  • 517
  • 1
  • 5
  • 16
  • Are you utilizing the "Start-Process" cmdlet or what? You can use "-NoNewWindow" but this will simply redirect the output to your embedded host. – cjones26 Jun 09 '15 at 15:06
  • Not the powershell invoke function is calling the underlying host process. This is where the issue is. – RG5 Jun 14 '15 at 17:11
  • You could look at an existing open-source host like ConEmu, http://conemu.github.io/en/Source.html. I can run ping from within it's command window without seeing a conhost, but I can also show the "Real Console" from the Debug menu. – Eris Jun 27 '15 at 22:26
  • Could you provide a minimal code example in your question for issue reproduction? – Dennis Nov 23 '21 at 18:19

1 Answers1

1

It's been a while since I asked this question so I wanted to share the answer I came up with. Basically, since my embedded host was in an application that runs solely in the background, there was no way to prevent conhost from flashing on the screen when "native commands" were processed. It's just the way Windows works. If my host was attached to a GUI then I think there might have been a way to redirect output, but so far for my use case I couldn't suppress conhost.

RG5
  • 517
  • 1
  • 5
  • 16