views:

75

answers:

2

I was wondering is there is a fool-proof way to run a program on windows such that I'm guaranteed that no interactive dialogs of any kind are displayed.

I've tried the registry ErrorMode hack, calling _CrtSetReportMode(), etc., but they all have holes in them or require you to modify the program.

I need a way to run an arbitrary program and practically force Windows to execute them such that there is no possibility for them to open a window. It is perfectly ok for the program to crash if it attempts to open a window.

Would running the program as a service solve the problem?

+1  A: 

I'm not aware of any other ways that might possibly work. Running as a service won't solve the problem either as the dialog will be displayed on the service's desktop, which you generally don't have access to.

Scott Dorman
What does that mean? Does the application still wait for the dialog to complete? I can accept that I'm not seeing the dialog (I can always rerun the build manually), as long as the application does not wait for the dialog.
JesperE
Even when running a program on the nonvisible service desktop, it will still wait for the nonexistent user to press a nonvisible button to dismiss the dialog box. This is probably not what you want.
Greg Hewgill
How meaningless. As usual, the lack of design can be seen in every corner of Windows.
JesperE
Yes, as Greg mentioned, the application will still wait for a user response which is why running as a service won't solve your problem either.
Scott Dorman
+1  A: 

You could use a library such as Detours to intercept all calls to functions that might display a dialog box (this might in fact be nearly everything in user32.dll).

Greg Hewgill