1

I am creating a process to do some working. But the process is starting a black window (like the cmd). I have tried to set the CreateNoWindow = true but that doesn't help.

Is there another way to disallow window creation?

Here is my code:

var worker1 = new Process();

worker1.EnableRaisingEvents = true;
worker1.StartInfo.CreateNoWindow = true;
worker1.StartInfo.ErrorDialog = true;
worker1.StartInfo.Arguments = job.BtcFilePath;
worker1.StartInfo.FileName = job.ExeFilePath;
worker1.Exited += new EventHandler(Worker1Exited);

Processors.Add(worker1);

Processors.Last().Start();
Processors.Last().PriorityClass = ProcessPriorityClass.BelowNormal;

*The Processors is a list of processors

BR

1 Answer 1

3
worker1.StartInfo.CreateNoWindow = true;
worker1.StartInfo.UseShellExecute = false;

This worked for me in a similar situation.

worker1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

This seems to be another option. (Did not test this, but found this while browsing http://www.dotnetperls.com/png)

2
  • Perfect :D Can you explain me what it does?
    – 7heViking
    Apr 4, 2012 at 8:13
  • 1
    Description for UseShellExecute: true if the shell should be used when starting the process; false if the process should be created directly from the executable file. The default is true. - The shell manages all windows (I assume it does anyway,) so not using the shell will stop the window from being created.
    – Thomas
    Apr 4, 2012 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.