Search code examples
c#multithreadingmessageboxthread-sleepprocess.start

How can I force another program to not show any dialog when I run it with Process.Start()


I'm not sure if it's possible anyway. But my question is, can I force a program to not show any dialogs when I run it with process.Start()?

I have a program where I call another program in a foreach loop. It is a fileconverter. Unfortunately some files don't exist any more or the user gives the wrong filepath. If that happens, the converter shows an error with a messagebox. But i don't want to see that box, because if the user wants to convert 10000 files, but has the wrong path in settings, 10000 messagboxes appear and force the system to crash.

I have tried to kill these processes but they have the same name in the processes as the converter itself. I can handle it with a Thread.Sleep but then my mouse is flickering all the time while my thread is running. This is just a little bit better than the messageboxes.

If there is a way, I would be very thankful if you could tell me :)

Regards Schlinger


Solution

  • Most probably it's not possible. There is no built-in way to prevent any executable to show any dialog box.

    Depending on the executable you're running, with some luck it might expose a command line version that accepts some quiet or noui parameter, but it's unlikely.

    Or you could try programmatically closing those dialog boxes, as suggested.