I have 2 programs (.exe) which I’ve created in .NET. We’ll call them the Master and the Worker. The Master starts 1 or more Workers. The Worker will not be interacted with by the user, but it is a WinForms app that receives commands and runs WinForms components based on the commands it receives from the Master.
I want the Worker app to run completely hidden (except showing up in the Task Manager of course). I thought that I could accomplish this with the StartInfo.CreateNoWindow and StartInfo.WindowStyle properties, but I still see the Client.exe window and components in the form. However, it doesn’t show up in the taskbar.
Process process = new Process
{
EnableRaisingEvents = true,
StartInfo =
{
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "Client.exe",
UseShellExecute = false,
ErrorDialog = false,
}
};
What do I need to do to let Client.exe run, but not show up?ㅤㅤㅤㅤㅤ
Your usage of
CreateNoWindow/WindowStyleworks fine on my system with notepad.exe (e.g. it is hidden but running in the background), so it’s probably something the WinForms app is doing. Some ideas:Option 1: If you control the WinForms worker process, you can override
Control.SetVisibleCoreto always hide the form. If you don’t want to always hide it, you can pass a command-line argument to it, e.g./hidethat will cause it to be hidden. Example (assuming there’s already code-behind for the form):With this, running
MyForm.exeresults in a process with a visible form. RunningMyForm.exe /hideresults in a process with a hidden form. You could pass the/hideargument from your master process, so then normal users running the application will still see it.Option 2: You can hide the application after it starts by doing a P/Invoke to
ShowWindow. More info on this here. This has the drawback that you can sometimes see the worker window flicker into existence before being hidden. Example: