zeencat zeencat -4 years ago 108
C# Question

Hide System.Diagnostics.Process GUI window

I'm really struggling with the following problem. I know that there are similar questions to my scenario but non of them are exactly the same scenario.

I've created an SSIS custom component that starts an external application that I want to run in silent mode. No matter what I try the gui always appears. If I use the same code in a console application I don't run into any issues at all. The only difference I can see between my SSIS custom component (dll) and the console application is that my component references System.Windows.Forms and uses BIDS. I'm using the following code. Any tips I'm more than willing to try.

Process winscp = new Process();

winscp.StartInfo.FileName = @stExe;
winscp.StartInfo.Arguments = "/log=";
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;


Answer Source

Try to find the window of the new process, hide it as soon as possible.

Use Win32 API,

HWND hwnd = FindWindow(NULL, "Title");
ShowWindow(hwnd, SW_HIDE);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download